MYSQL QUESTION< CAN YOU HELP?

i have a PHP script with a sql statement that accesses a database. this script will pull each record, however. If i wanted i could restrict the records to be pulled to let us state 20 per page.
now the question: i wish to create a “”click next” button so that the user can navigate to the next 20 then next 20 and so on. how can i go by doing that? if i had 1 million records, of course when the user runs the script he or she will see a large large page and will take time for dquery to run. what is the solution here?
of course i have a search engine, which will help search by certain criteria, but i wish the user to access the whole data as well.
Xizzi, thanks a lot, that should definitely help, up to the point. Good place to spend the weekend for me ![]()
great answer.
Bernz, good points, thanks a lot.
didnt know dreamweaver could do that, seems like it is time for me that i used it.
about 1 year ago
Does this help? http://www.plus2net.com/php_tutorial/php_paging.php
about 1 year ago
Well, you have 2 possibilities:
1. EASY solution:
use Dreamweaver. It’s made for PHP / MySQL connectivity and it manages this paging stuff very very well!
2. HARDER solution:
for large amounts of data, you need to play alot with your SQL query, not PHP that much… Your bottleneck will be MySQL. Therefore, read the MySQL optimization techniques.
One obvious this is that you’ll need to use the “SELECT … LIMIT x, y” clause that will extract from x to y in your recordset.
Now, one of the common errors is the way that you calculate your TOTAL amount of data. If you LIMIT your SELECT, then you don’t actually get the total amount, UNLESS you ask for it. So, use the SQL_CALC_FOUND_ROWS SQL statement (see link below). This is VERY powerful for millions of records.
Do NOT use the query SELECT COUNT(*) AS MAXROWS FROM MYTABLE. This is VERY slow.
Good luck!