view_pagging.php
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("product",$link);
$page_q="select * from mobile";
$page_res=mysql_query($page_q,$link);
$item=3;
$total_record=mysql_num_rows($page_res);
$total_page=ceil($total_record/$item);
$cur_page=(isset($_GET['page']))?$_GET['page']:1;
?>
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
</tr>
<?php
$k=($cur_page-1)*$item;
$q="select * from mobile LIMIT $k,$item";
$res=mysql_query($q,$link);
while($row=mysql_fetch_array($res))
{
echo '<tr align="center">
<td>'.$row['id'].'
<td>'.$row['nm'].'
</tr>';
}
?>
</table>
<center>
<?php
if($cur_page>1)
{
echo '<a href="view_pagging.php?page='.($cur_page-1).'">Previous </a>';
}
else
{
echo 'Previous';
}
for($i=1;$i<=$total_page;$i++)
{
echo '<a href="view_pagging.php?page='.$i.'">'.$i.'</a> ';
}
if($cur_page<$total_page)
{
echo '<a href="view_pagging.php?page='.($cur_page+1).'">Next</a>';
}
else{
echo 'Next';
}
?>
</center>
</body>
</html>
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("product",$link);
$page_q="select * from mobile";
$page_res=mysql_query($page_q,$link);
$item=3;
$total_record=mysql_num_rows($page_res);
$total_page=ceil($total_record/$item);
$cur_page=(isset($_GET['page']))?$_GET['page']:1;
?>
<html>
<body>
<table border="1" width="50%" align="center">
<tr>
<th>No</th>
<th>Name</th>
</tr>
<?php
$k=($cur_page-1)*$item;
$q="select * from mobile LIMIT $k,$item";
$res=mysql_query($q,$link);
while($row=mysql_fetch_array($res))
{
echo '<tr align="center">
<td>'.$row['id'].'
<td>'.$row['nm'].'
</tr>';
}
?>
</table>
<center>
<?php
if($cur_page>1)
{
echo '<a href="view_pagging.php?page='.($cur_page-1).'">Previous </a>';
}
else
{
echo 'Previous';
}
for($i=1;$i<=$total_page;$i++)
{
echo '<a href="view_pagging.php?page='.$i.'">'.$i.'</a> ';
}
if($cur_page<$total_page)
{
echo '<a href="view_pagging.php?page='.($cur_page+1).'">Next</a>';
}
else{
echo 'Next';
}
?>
</center>
</body>
</html>