I am new to php and sql, and i have one tiny question about how to realize sql query , that can:
- Take for example 5 entries from DB, insert them on 1st page (1-5)
- Than take next 5 entries from same DB and insert them on another page (5-10)
and so on :)
Thank you )
If your query does not return a prohibitive amount of results, consider using Jquery to page it with a Tablesorter function. It takes a properly formatted HTML table and pages, sorts, etc on the fly...no need for additional query variables if you don't wish. It's SO much easier than going the full-blown PHP paging route, and is much faster for the user.
My personal favorite example is here: http://datatables.net/
It may not fully suit your needs, but it is cool for many applications. If you do it, just don't forget to format your table with thead and tbody so that it can properly pick up the table elements.
Read the LIMIT section on the MySQL SELECT helppage. If you want to display the total number of rows available, you can either do an extra count, or use the ROW_COUNT function.
There are several ways to do this, I think the fastest performance is following one:
Stuff you should use: