Re: limiting rows and pages like google -- again

From: Date: Thu, 13 Sep 2001 07:01:45 +0000
Subject: Re: limiting rows and pages like google -- again
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67150@lists.php.net to get a copy of this message
i spent a good day learning how to do this from scratch. I'll post my code and you can decypher it yourself. <?php $select_all = mysql_query("SELECT id FROM images WHERE directory='original'"); $select_result = mysql_result($select_all,0); $select_numrows = mysql_num_rows($select_all); $i=1; if (!isset($page)) { $page = 1; } if ($page != 1 ) { if (($page-1) == 1) { echo '<a href="'.$PHP_SELF.'">&laquo;previous</a>&nbsp;'; }else{ echo '<a href="'.$PHP_SELF.'?page='.($page-1).'">&laquo;previous</a>&nbsp;'; } } else { echo '<font color="#999999">&laquo;previous</font>&nbsp;'; } while ($select_numrows > 0) { if ($page != $i) { if ($i==1){ echo '<a href="'.$PHP_SELF.'">'.$i.'</a>&nbsp;'; } else{ echo '<a href="'.$PHP_SELF.'?page='.$i.'">'.$i.'</a>&nbsp;'; } } else { echo '<font color="#999999">'.$i.'</font>&nbsp;'; } $i = $i+1; $select_numrows = $select_numrows-20; } if ($page < ($i-1)) { echo '<a href="'.$PHP_SELF.'?page='.($page+1).'">next&raquo;</a>&nbsp;&nbsp;'; } else { echo '<font color="#999999">next&raquo;</font>&nbsp;&nbsp;'; } ?> hope this helps. it took 2 days straight to debug and develope. obviously you would use different database values though. -Adam god bless amarica

« previous php.general (#67150) next »