I want to design pagination for desktop and mobile devices with the condition that on desktop view i want to display the 3 rows max And in mobile view i want to display the 1 row max per page i have the following pagination script which is working for static condition but i want it dynamic for desktop and mobile. Please help me and thanks in advance.
PHP script
<html>
<body>
<div id="content">
<?php
$query1=mysql_connect("localhost","root","");
mysql_select_db("customer_fetcher",$query1);
$start=0;
$limit=1;
$id = 1;
if(isset($_GET['id']))
{
$id=$_GET['id'];
$start=($id-1)*$limit;
}
$query=mysql_query("select * from test LIMIT $start, $limit");
echo "<ul>";
while($query2=mysql_fetch_array($query))
{
echo "<li>".$query2['name']."</li>";
}
echo "</ul>";
$rows=mysql_num_rows(mysql_query("select * from test"));
$total=ceil($rows/$limit);
if($id>1)
{
echo "<a href='?id=".($id-1)."' class='button'>PREVIOUS</a>";
}
if($id!=$total)
{
echo "<a href='?id=".($id+1)."' class='button'>NEXT</a>";
}
echo "<ul class='page'>";
for($i=1;$i<=$total;$i++)
{
if($i==$id) { echo "<li class='current'>".$i."</li>"; }
else { echo "<li><a href='?id=".$i."'>".$i."</a></li>"; }
}
echo "</ul>";
?>
</div>
</body>
</html>