Jump to content

Splitting a search result over multiple pages


MortimerJazz

Recommended Posts

Just a quick question ...

When running a query through a database, I may well end up getting 20 or 30 matches displayed on the screen. While this isn't exactly a problem, I think it would look better if I was able to split that up so that 10 matches were displayed on three different pages with links at the bottom of each page for a user to click through to see the next set of results.

Can someone explain the best way to go about this please?

Thanks
I think what you want is to add "LIMIT [number to start at] , [number to show in total]" to the end of your mysql_query.

[Number to start at] is the number you want the database to start returning values. Say you have 30 results normally, it would start showing from this point in the found matches.

[Number to show] is the number of rows to return. In your case you want it to be 10.


So you would want to add "LIMIT 0 , 10" for the first page. "LIMIT 9 , 10" for the second. "LIMIT 19 , 10" for the third and so on.
Thanks for the reply Kairu.

How would I set up the links at the bottom of the page though? Would I need to call the SQL query each time a link was clicked? And even if I had to, how would that get coded into a single HTML link?
I'm not sure at all if it's the easiest way, but you would need to refresh the page with new variables.

Perhaps a hidden form? The submit button being the "Next Page" Button where it refreshes the page? I'm sorry I can't be of more help at the moment. My keyboard's software just went buggy (last few minutes) and I am using someone elses. (Running out of time, sry! )

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.