Welcome Guest, Not a member yet? Register   Sign In
HELP | calling functions from controller
#1

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)? 

example:
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  [font=Menlo, Monaco,]window.location.href="<?php echo site_url ) [/font]

So how do I do it?

thanks!
Reply
#2

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB