if(isset($_GET['pg'])){
$pg=(int)$_GET['pg'];
}else{
$pg=1;
}
// i want to show 16 row on a page, so the limit is also 16
$start_from=($pg-1)*16;
$img_sql="SELECT *
FROM image_table
WHERE collection_ID=$cid
LIMIT $start_from,16";
// your sql query here
$res=mysql_query($img_sql)
// query execution, use mysqli_query()
// instead of mysql_query();
or die("Selection failed !".mysql_error());
$count_query=mysql_query("SELECT COUNT(*)
FROM image_table
WHERE collection_ID=$cid")
or die("Count query failed !".mysql_error());
// find out the total existing record on database table
$total_row=mysql_fetch_array($count_query);
$total_record=$total_row[0];
$total_pages=ceil($total_record/16);
// for showing the pagination link on your page this code
//will visulize the link
echo "<div style='float:right; margin:-8px 25px 0px auto;'>";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a style='color:orange'
href='newcollection.php?pg=".$i."&cid=".$cid."'>
<strong>".$i."</strong>
</a> ";
};
echo "</div>";
?>
Comments 5