Welcome Guest, Not a member yet? Register   Sign In
How to query database for Header.php
#1

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/9540...odeigniter 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
Reply
#2

@xBarns,

This is how you get data to an view ( https://codeigniter.com/user_guide/gener...o-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/1399...p/13991295 ) or a session variable ( https://codeigniter.com/user_guide/libra...sion-class )
Reply
#3

(11-23-2018, 09:38 AM)php_rocs Wrote: @xBarns,

This is how you get data to an view ( https://codeigniter.com/user_guide/gener...o-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/1399...p/13991295 ) or a session variable ( https://codeigniter.com/user_guide/libra...sion-class )

@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?
Reply
#4

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!
Reply
#5

@xBarns,

Sure no problem. Glad I could help.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB