Jump to content

Query on each separate web page for same data?


son

Recommended Posts

I have few web pages sitting in separate folder that have an extra style and top text that can be changed by end user, but stays consistent across all pages in the mentioned folder. I retrieve page data as content and feature photo for all pages individually, but wondered what way is best to do this for the extra style info and top text? If I run query on each page I might unnecessarily burden the web server, but then each page could be accessed directly and I need to make sure I check for the relevant data in database... did anyone do this before and has any recommendations?Son

Link to comment
Share on other sites

you can write the code for the query in one PHP file, and then just include that file in all your pages.

Link to comment
Share on other sites

you can write the code for the query in one PHP file, and then just include that file in all your pages.
I use a header and footer file that is included in all files and has those bits included. I normally assign a variable as $page = whatever id the data has in database at the top of the php file. Then I include the header file that runs the necessary queries to retrieve the data and so on... I just thought there might be a better way as the query that is not related to the individual page runs again for each page if you see what I mean...Son
Link to comment
Share on other sites

I use a header and footer file that is included in all files and has those bits included. I normally assign a variable as $page = whatever id the data has in database at the top of the php file. Then I include the header file that runs the necessary queries to retrieve the data and so on... I just thought there might be a better way as the query that is not related to the individual page runs again for each page if you see what I mean...Son
so are you saying you have multiple queries, one for each page, and you are just trying to filter out just having the query for the specific page be the only one that runs? If so, sicne you are getting a $page value, you could use a swtich statement, or if/else to check the value of $page and then only have that page's specific queries execute.
Link to comment
Share on other sites

so are you saying you have multiple queries, one for each page, and you are just trying to filter out just having the query for the specific page be the only one that runs? If so, sicne you are getting a $page value, you could use a swtich statement, or if/else to check the value of $page and then only have that page's specific queries execute.
No, the page specific queries are just another element I needed looking into. My question was only regarding the data that is and stays the same for all web pages. I have the query that retrieves the data in header file that is included in all files, so looks like the way I do this seems ok (after reading what you said). So, many thanks. will continue to do this as I did this before.Son
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...