Hey all,
I got a paging function which isn’t doing what i want it to do… it works fine on other pages but i dont know how to make it work with a mysql join in my php script heres the code i’ve got :-
Its displaying the right amount of page numbers but its still displaying all the images
[code=php]
$max = 2; //amount of images per page
$p = $_GET[‘p’];
if(empty($p))
{
$p = 1;
}
$limits = ($p – 1) * $max;
//view the image!
if(isset($_GET[‘act’]) && $_GET[‘act’] == “view”)
{
$id = $_GET[‘id’];
$query2 = “SELECT likes.imgid, COUNT(likes.imgid), img.name, img.tagged FROM likes, img WHERE likes.imgid = img.imgid GROUP BY likes.imgid ORDER BY COUNT(likes.imgid) DESC”;
$result2 = mysql_query($query2) or die(mysql_error());
while($info = mysql_fetch_array( $result2 ))
{
$szImgId = $info[‘imgid’];
//Outputs the images
echo “<li><a href=”all_pics.php?id=$szImgId”><img src=/”.$thumb.”>”.”<p>” .$info[‘tagged’].”</p></a></li>” ;
}
}else{
//view all the images in rows
$sql = mysql_query(“SELECT likes.imgid, COUNT(likes.imgid), img.name, img.tagged FROM likes, img WHERE likes.imgid = img.imgid GROUP BY likes.imgid ORDER BY COUNT(likes.imgid) DESC LIMIT “.$limits.”,$max”) or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query(“SELECT COUNT(likes.imgid) AS tot FROM likes, img WHERE likes.imgid = img.imgid”),0);
//the total number of pages
$totalpages = ceil($totalres / $max);
while($info = mysql_fetch_array( $result2 ))
{
$szImgId = $info[‘imgid’];
//Outputs the images
echo “<li><a href=”all_pics.php?id=$szImgId”><img src=/”.$thumb.”>”.”<p>” .$info[‘tagged’].”</p></a></li>” ;
}
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo “<a href=’index.php?p=$i’>$i</a>|”;
}
}
any ideas what to change?
thanks in adavnced