This is enhancement of Page Scroller, I add a total records amount and NEXT PREV condition so the PREV link wont show in the first page and NEXT link wont show in the last page.
By : wibi
<? /******************************************************************** * page scroller code snippet. * * Copyright (C) 2001 Wibisono Sastrodiwiryo. * This program is free software licensed under the * GNU General Public License (GPL). * * CyberGL => Application Service Provider * http://www.cybergl.co.id * office@cybergl.co.id * * $Id: scroller2.php3,v 0.2 2001/06/4 15:29:53 wibi Exp $ *********************************************************************/
$script="scroller2.php3"; $offset+=0; $item_perpage= 2; #----change this to define how many item per page $prev= $offset-$item_perpage; $next= $offset+$item_perpage;
$query="SELECT $field FROM $tbl_search WHERE $field LIKE '%$keyword%' LIMIT $offset, $item_perpage"; $querytotal="SELECT count(*) FROM $tbl_search WHERE $field LIKE '%$keyword%'"; $total=mysql_fetch_row(mysql_query($querytotal));
#----modify the where clause to fit your query need
#---------------------------------------prev next condition if ($prev < 0) {$prev="";} else {$prev="<a href=\"$script?offset=$prev&keyword=$keyword\"><< PREV</a>";} if ($total[0] > $next) {$next="<a href=\"$script?offset=$next&keyword=$keyword\">NEXT >></a>";} else {$next="";}
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.