have a look at the PEAR Pager class. very useful. _________________________ ----- Original Message ----- From: "David Ziggy Lubowa" <dlubowa@xxxxxxxxxxx> To: <php-db@xxxxxxxxxxxxx> Sent: 16 December 2004 23:38 Subject: Pagination > > > Hey guys, > > I am working on an internal db and i have a script[below] which does some > searching for me, now i am no expert in php but atleast i can always read up, > i want to add some kind of pagination because just incase i search for > somethign in particular i dont want it to display 100 entries on my form, how > can i incorperate a pagination script in the script below, > > all help is highly appreciated > > [snip] > > > <?php > > $var = @$_GET['q'] ; > $trimmed = trim($var); > > // check for an empty string and display a message. > if ($trimmed == "") > { > echo "<p>Please enter a search...</p>"; > exit; > } > > > $link = mysql_connect("localhost", "beef","b33f"); > mysql_select_db("ip", $link); > $qry = mysql_query("SELECT * FROM IP_Addresses where free like '%". > $_GET['q']."%'", $link); > > ?> > <table border="1" width="100%"><tr><?php > > if (mysql_num_rows($qry)==0 ) { > > print " Oops No records found "; > ?> > <br> > <a href="http://localhost/ipsearch2.html">Back</a> > </br> > <? > exit(); > } > if (mysql_num_rows($qry) > 0) { > for ($i = 0; $i<mysql_num_fields($qry); $i++) { > echo "<td align=center><strong>" . mysql_field_name($qry, $i) . > "</td>"; echo "<td align=center><strong>" . mysql_field_name($qry, > $i) . "</td>"; > } > } > > ?> > > </tr><?php > > if (mysql_num_rows($qry) > 0) { > for ($j = 0; $j<mysql_num_rows($qry); $j++) { > > ?><tr><?php > > for ($k = 0; $k<mysql_num_fields($qry); $k++) { > echo "<td align=center>" . mysql_result($qry,$j, $k) . "</td>"; > } > > ?></tr><?php > > } > } > > ?> > > [/snip] > > cheers > > -Z > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php