I want to divide my data to pages. And I think I am almost there except a little mildly problem.
My output on first page which is excellent:
My output on other pages which is where the problem is occurring:
Other pages doen't look nice. My code is below, I would really appreciate if someone wants to help.
<?php
$per_page = 1; //limit
if(intval(@$_GET['page']))
{
$page = intval(@$_GET['page']);
}else{
$page= 0;
}
$id = $_GET['id'];
$data2=mysql_query("select id from files where cat=".$_GET['id']."");
$data=mysql_num_rows($girdi2);
$toplam=ceil($data/$per_page);
$r_now = $page * $sayfa_basina;
$f_data = mysql_query("select * from files where cat=".$_GET['id']." order by id desc limit $r_now, $per_page");
while($r=mysql_fetch_array($f_data)) {
echo "<td><a href='file.php?id=$r[id]'><b>$r[title]</b></a></td>";
}
####Pagination####
for ($i = 0; $i <= $toplam-1; $i++)
{
if(!$page != $i) { printf('<a href="?id='.$id.'&page=%d"><b>%d</b></a> ', $i, $i+1); }
else { printf('<a href="?id='.$id.'&page=%d">[%d]</a> ', $i, $i+1); }
} ?>
Thanks.