[PHP] NEXT Page and BACK Page
Dear list, I would like to query only the last 50 records/rows (order by ID desc) in the following script file which uses MySQL, and I want to have NEXT page for the 50 rows earlier than last 50 queried and go on. I think I can use JavaScript for BACK page to go back. Could you pl add for me the script to implement NEXT page. Here is the script file: html body ?php $db = mysql_connect(localhost, root, root); mysql_select_db(penpal,$db); if ($id) $result = mysql_query(select * from penpal where id = $id,$db); $myrow = mysql_fetch_array($result); printf(bID:/b %s\nbr, $myrow[id]); printf(bName:/b %s\nbr, $myrow[name]); printf(bAge/Sex/Location:/b %s\nbr, $myrow[asl]); printf(bDescription:/b %s\nbr, $myrow[description]); printf(bEmail:/b %s\nbr, $myrow[email]); } else { $result = mysql_query(select * from penpal order by id desc, $db); if ($myrow = mysql_fetch_array($result)) { do { printf(a href = \%s?id=%s\%s %s/abr\n, $PHP_SELF, $myrow[id], $myrow[name], $myrow[asl]); } while ($myrow = mysql_fetch_array($result)); } else { echo Sorry, no records; } } ? /body /html Thank you in advance. NOBBY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] NEXT Page and BACK Page
Use a LIMIT clause. See http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#SELECT -Rasmus On Tue, 23 Oct 2001, Tshering Norbu wrote: Dear list, I would like to query only the last 50 records/rows (order by ID desc) in the following script file which uses MySQL, and I want to have NEXT page for the 50 rows earlier than last 50 queried and go on. I think I can use JavaScript for BACK page to go back. Could you pl add for me the script to implement NEXT page. Here is the script file: html body ?php $db = mysql_connect(localhost, root, root); mysql_select_db(penpal,$db); if ($id) $result = mysql_query(select * from penpal where id = $id,$db); $myrow = mysql_fetch_array($result); printf(bID:/b %s\nbr, $myrow[id]); printf(bName:/b %s\nbr, $myrow[name]); printf(bAge/Sex/Location:/b %s\nbr, $myrow[asl]); printf(bDescription:/b %s\nbr, $myrow[description]); printf(bEmail:/b %s\nbr, $myrow[email]); } else { $result = mysql_query(select * from penpal order by id desc, $db); if ($myrow = mysql_fetch_array($result)) { do { printf(a href = \%s?id=%s\%s %s/abr\n, $PHP_SELF, $myrow[id], $myrow[name], $myrow[asl]); } while ($myrow = mysql_fetch_array($result)); } else { echo Sorry, no records; } } ? /body /html Thank you in advance. NOBBY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Again: [PHP] NEXT Page and BACK Page
Use a LIMIT clause. See http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#SEL ECT -Rasmus And for a db that not have limit (like ibm db2) Josep. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Again: [PHP] NEXT Page and BACK Page
Use a LIMIT clause. See http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#SEL ECT -Rasmus And for a db that not have limit (like ibm db2) Use a cursor or rowcount, if you have that. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] NEXT Page and BACK page
Dear list, I would like to query only the last 50 records/rows (order by ID desc) in the following script file which uses MySQL, and I want to have NEXT page for the 50 rows earlier than last 50 queried and go on. I think I can use JavaScript for BACK page to go back. Could you pl add for me the script to implement NEXT page. Here is the script file: html body ?php $db = mysql_connect(localhost, root, root); mysql_select_db(penpal,$db); if ($id) $result = mysql_query(select * from penpal where id = $id,$db); $myrow = mysql_fetch_array($result); printf(bID:/b %s\nbr, $myrow[id]); printf(bName:/b %s\nbr, $myrow[name]); printf(bAge/Sex/Location:/b %s\nbr, $myrow[asl]); printf(bDescription:/b %s\nbr, $myrow[description]); printf(bEmail:/b %s\nbr, $myrow[email]); } else { $result = mysql_query(select * from penpal order by id desc, $db); if ($myrow = mysql_fetch_array($result)) { do { printf(a href = \%s?id=%s\%s %s/abr\n, $PHP_SELF, $myrow[id], $myrow[name], $myrow[asl]); } while ($myrow = mysql_fetch_array($result)); } else { echo Sorry, no records; } } ? /body /html Thank you in advance. NOBBY