adamlacombe Posted July 7, 2009 Share Posted July 7, 2009 Ok, I have a problem with paging, I have 4 rows that should show but when the perpage is at 2 only two show up and if I go to page two none show up, two more should though. This is what I got so far: <? $perpage=2; //perpage $page=$_GET['pageid']; if($page>0){ $start=$page*$perpage; }else{ $start=0; }//end if $cres=mysql_query("SELECT COUNT(*) FROM favorites WHERE username='{$_SESSION['username']}'"); $crow=mysql_fetch_array($cres); $count=$crow[0]; //build the pagination $linker=''; if($count>$perpage){ for($i=1;$i<ceil($count/$perpage);$i++){ $linker.="<a href=\"index.php?action=favorites&pageid=$i\">$i</a> - "; }//end for }//end if ////////////////// ////////////////// echo "<table align='center'>"; echo "<tr><td colspan='2' width='50%' align='center'>Favorites</td></tr>\n"; $a=0; $fav=mysql_query("SELECT * FROM favorites WHERE username='{$_SESSION['username']}' LIMIT $start,$perpage"); while($fav2=mysql_fetch_array($fav)){ $cat=$fav2[pagecat]; $pageid=$fav2[pageid]; if ($a=='0'){echo "<tr>";} echo "<td width='50%'>"; echo "<table>"; echo "<tr><td align='center' colspan='2'><b>$cat</b></center><hr></hr></td></tr>"; $res2=mysql_query("SELECT * FROM $cat WHERE game_id='$pageid'"); while($favn=mysql_fetch_array($res2)){ $id=$favn['game_id']; $views=$favn['game_views']; $name=$favn['game_name']; $thumb=$favn['game_thumb']; $des=substr($favn['game_des'], 0, 38); $type=$favn['game_type']; if($type=='h'){ $image="<center><img src='games/thumbs/$thumb' height='81' width='81' /></center>"; }else{ $image="<center><img src='$thumb' height='81' width='81' /></center>"; } echo "<tr>"; echo "<td class='content' width='81'><a href=index.php?action=$cat&id=$id>$image</a></td>"; echo "<td class='content' width='50%'><a href=index.php?action=$cat&id=$id>$name</a><br /><small>$des...<br />Played $views Times</small></td>"; echo "</tr>"; }//end while echo "</table>"; echo "</td>"; $a++; if ($a=='2'){echo "</tr>";$a=0;} }//end while echo "<tr><td colspan=2 align=center>$linker</td></tr>\n"; echo "</table>"; ?> Any idea on whats causing that problem? Thanks in advanced! Quote Link to comment https://forums.phpfreaks.com/topic/165109-paging-problem/ Share on other sites More sharing options...
kickstart Posted July 8, 2009 Share Posted July 8, 2009 Hi Brief look and you code should work if the page numbers are 0, 1, 2, etc. However if you page numbers start at 1 then the first page you show would be the 2nd page. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/165109-paging-problem/#findComment-870920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.