jonniejoejonson Posted February 9, 2008 Share Posted February 9, 2008 When a website like facebook displays thumnails of all your photos but you have so many that it spreads over many pages. 1/ Do they query the database for the image names every time the page is turned... orr 2/ Do they get all the images names on the first page then save that data in a session so that you dont have to query the database so often... thanks to any responders. Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/ Share on other sites More sharing options...
cooldude832 Posted February 9, 2008 Share Posted February 9, 2008 read the tutorial here on pagination Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-462832 Share on other sites More sharing options...
pocobueno1388 Posted February 9, 2008 Share Posted February 9, 2008 You do something called "pagination". Google "PHP pagination tutorial" and you should get plenty of results. Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-462833 Share on other sites More sharing options...
jonniejoejonson Posted February 9, 2008 Author Share Posted February 9, 2008 Cheers guys but i've checked out tutorials on pagination, I was just wandering which would be better... the turoials all show use the first example that queries the database each time, I was just thinking that maybe for a large site like facebook it would better to use my second example. thanks J. Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-462851 Share on other sites More sharing options...
cooldude832 Posted February 9, 2008 Share Posted February 9, 2008 thats even a worse idea to store a say 1000 image names first you lose the power of the mysql LIMIT function Secondly you only have image names, mysql can store more than that like Comments or image titles, sizes, dates, etc. Third image having 50k users * 1000 images in a gallery all being viewed at once, then image that all going in your session data (If you don't know this is a bad thing) Forthly You are going to have to do some ugly manual array sorting. Conclusion Let MySQL do it. Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-462852 Share on other sites More sharing options...
rcorlew Posted February 10, 2008 Share Posted February 10, 2008 I have done a "sort of" combination of both. I do a num_rows query and then storing that in a session variable to aid in the speed of pagination. But you will have to use pagination no doubt. Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-463080 Share on other sites More sharing options...
cooldude832 Posted February 10, 2008 Share Posted February 10, 2008 issue with storing the count is that it could alter between page loads. Better way is to query on demand for it. If you had a highly volatile system like ebay the pagination is constantly shifting. Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-463091 Share on other sites More sharing options...
rcorlew Posted February 10, 2008 Share Posted February 10, 2008 cooldude, you are absolutely right, it would only work with a fixed db system, which is how I used it. jonniejoejonson, you will have to write very good queries to avoid overhead if indeed there will be as many rows per query/request Quote Link to comment https://forums.phpfreaks.com/topic/90272-creating-pages/#findComment-463101 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.