Amrit http://www.bytesworth.com
Bj wrote:
----- Original Message ----- From: "Amrit Hallan"
When I show the result of a query, the entire result
comes on the page, even if there are 100s of
returned rows. How can I show the result page-wise
(for example, the footer of Google where you see
1 2 3 4 5 ...Next)?
The way I do it is by using mysql_data_seek() and a variable $Start to keep track of where I am in the results. Mysql_data_seek(result, row number) sets a mysql pointer to the specified row number in the result so that's the next one you fetch with mysql_fetch_array().
If $Start is not defined, set to 0 Execute the query Seek to row '$Start' Fetch rows and display them until you have displayed 20, or reached the end of the results If not at the end, add 20 to $Start and give the user a "Next" link to click that will call the page again, passing the current value of '$Start' in a querystring
You can make this more complicated, as much as you like. Mysql_num_rows will tell you how many rows are in the query, so you can have links like Google for page 1, 2, 3... each with a different start number. You can also see if 'start - 20' is greater than 0 and if so, you can have a "Back" or "Prev" link.
I could show you my code of course, but then I'd have to kill you. I think you are more than bright enough to work it out from this! :-)
Bj
____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016
Please include the email address which you have been contacted with.