Enter Keyword Hear for Search This Blog

Showing posts with label How to create pagging system using php. Show all posts
Showing posts with label How to create pagging system using php. Show all posts

Saturday, 23 April 2016

How to create pagging system using php

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>

Featured post

what is ajax?how to create ajax with php code

Ajax Introduction -  એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો...