Welcome Guest, Not a member yet? Register   Sign In
Database Query & Result on Every Page
#1

[eluser]coxdabd[/eluser]
Hi all, I've been racking my brain on a solution to my problem but to no avail.

I need to add to the footer of every-page of my site customer feedback - which is in my database. What is the best way to smash this?

Ideally a way which would take little effect on changing the rest of the code on the site...
#2

[eluser]boltsabre[/eluser]
Research caching with CI, this will solve your problem!
#3

[eluser]smilie[/eluser]
I don't think that is what he was asking, simply because MySQL by default installation also caches results until table (data) has been changed. I think (and I may be wrong) that he is looking for HTML part of how to do it without having to edit each existing page.

In that case, you will need to (once) re-factor your HTML code to break it into header - content - footer;

Cheers,
Smilie
#4

[eluser]boltsabre[/eluser]
Oh right, yes, that makes a bit more sense now I've re-read the question!

>> you will need to (once) re-factor your
hehe, this could be a BIG job depending on how large the site already is, but better to bite the bullet and do it now rather than later when it's even bigger!
#5

[eluser]zauber[/eluser]
I suggest extending the controller, and instead of making your controllers extend CI_Controller, they extend your MY_Controller.

It's in the UserGuide, but this article makes it more clear how useful this technique is:

http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY

The MY_Controller can do the db query and use $this->load->vars() to make it available in views. In your footer just use the variables you loaded.




Theme © iAndrew 2016 - Forum software by © MyBB