Jump to content

Paging problem


adamlacombe

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/165109-paging-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.