![]() |
How to query database for Header.php - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: How to query database for Header.php (/showthread.php?tid=72221) |
How to query database for Header.php - xBarns - 11-23-2018 Hi all, first of all, thanks for such a nice product, it helped me quite nicely to achieve what i needed. To my question, i utilized the information in https://stackoverflow.com/questions/9540576/header-and-footer-in-codeigniter to load a header and footer for my website. My header contains a drop down (in a slide out menu, using js), the contents of which i would like to fill from a database query. I am using database queries in for my "templates", but for some reason i fail to understand how i would go on and do this for my header. And while i am at it, how would i store a variable for permanent use, the above mentioned drop down is supposed to select a "default" project, which is seldomly changed, thus (it's ID) should be available throughout the use of other pages of the website. If this is answered anywhere please let me know, i did use the search but either i am too blonde or i didn't look for the right keyword. Thanks a lot! x RE: How to query database for Header.php - php_rocs - 11-23-2018 @xBarns, This is how you get data to an view ( https://codeigniter.com/user_guide/general/views.html?highlight=data%20view#adding-dynamic-data-to-the-view ) There are a couple of ways to store a value for permanent use. It can be a global constant ( https://stackoverflow.com/questions/13990926/how-to-define-global-constants-in-codeigniter-in-constants-php/13991295 ) or a session variable ( https://codeigniter.com/user_guide/libraries/sessions.html?highlight=global%20variable#using-the-session-class ) RE: How to query database for Header.php - xBarns - 11-23-2018 (11-23-2018, 09:38 AM)php_rocs Wrote: @xBarns, @php_rocs, thanks, i know about how to pass the data, my question was more in the direction of where do i query the database, i tried in the "template" function but it did not work. Thanks for pointing out how to store variables, just for my understanding though, constants would not be changeablre right? RE: How to query database for Header.php - xBarns - 11-23-2018 Grrrrr, never mind my last reply, reading and understaning are sometimes two different things. I got it to work, just had to place it right. Thanks! RE: How to query database for Header.php - php_rocs - 11-23-2018 @xBarns, Sure no problem. Glad I could help. |