CodeIgniter Forums
HELP | calling functions from controller - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: HELP | calling functions from controller (/showthread.php?tid=79032)

HELP | calling functions from controller - Kizumaru - 04-11-2021

Hiya all,
I have worked with codegniter previously and just came back to it now and I guess im a bit rusty.

I can't figure out the following problem:
What is the best solution to call functions from a view (lets say I want to move to a new page from page X, which is a PHP page that uses SQL queries that I have on controller X)? 

From my homepage I want to move to the 'Library' page (which uses a custom SQL script).
When I use href it won't load the script.
The controller function that calls for the model function with the SQL query is there but it wont load (also with  window.location.href="<?php echo site_url ) 

So how do I do it?


RE: HELP | calling functions from controller - includebeer - 04-15-2021

You are mixing everything. If you want to go to another page, you won't load a function from the view. You will click on a link (href) that will take you to that other page. Everything starts from the controller. It will load what it needs (models, libraries, helpers...), then load a view. If you can't load the page by entering its URL in the browser address bar, then something is wrong with your controller or the routes configuration. Do you have any error message? If you have 404, your controller or route config is wrong. If you have 500, your code is crashing. Check the log files for more details about the crash.