Welcome to WebmasterWorld Guest from 188.8.131.52
Say I have 205 articles in a DB and I want to provide 10 links per page to these articles. (like SERP's)
What's the best/most efficient way of handling it in PHP?
Here's what I've been mulling over:
Retreive all of the unique ID's into an array then work it from there using sessions.
er.... that's all I came up with ;)
Or you can use LIMIT on the first search as well and then get the total number of matching records with a "SELECT count(*) your query".
Not sure which one is faster. I use the first approach. The total number of rows is used for a navigation like "prev 1 2 3 4 5 6 next".
This involves having 4 parameters: offset, no of results to return, no of total results, query string.
Hope this helps.
This keeps array size to a minimum and the math to calculate all of the different offsets is very fast.
Problem is that I'm writing my url's like this:
site.com/catagory // index of articles
site.com/category/11 // individual article
Could I do similar with a structure like that?
I was thinking of maybe having 20 links with descriptions on the index and then a link to all articles which would just be a list of all the titles in the db?