che_anj
08-29-2007, 02:16 PM
Hello,
Anyone has example of pagination?
I have made but its very basic procedural.. Id like to make it functional
this is my code .. accept critics.. ..
if(isset($_GET['start']))
{
$start=$_GET['start'];
$limit=$_GET['limit'];
}
else
{
$start=0;
$limit=15;
}
$query="SELECT * FROM users LIMIT $start, $limit";
$queryall="SELECT * FROM users";
$result = dbquery($link,$query);
$resultall=dbquery($link,$queryall);
$numrows=mysql_num_rows($resultall);
if(mysql_num_rows($result) < 1 )
{
echo 'no results found';
}
else
{
echo $num = $row[0];
while($row=mysql_fetch_array($result))
{
<tr>
<td><? echo $row['username'] ?> </td>
<td><? echo $row[firstname] ?></td>
<td><? php echo $row[lastname] ?></td>
<td><?php echo $row[email] ?></td>
</tr>
<?php
}
<tr><td colspan="6" align="center" height="20" class="table-list-title"><b>Result Page </b>
<?
$numofpages=$numrows/$limit;
if(($numrows % $limit)!=0)
$numofpages=$numofpages+1;
for($i=1,$start=0;$i<=$numofpages;$i++)
{
echo '<span class="char"><A href="'; echo $_SERVER["PHP_SELF"]; echo '?click=userlist.php&start='.$start.'&limit='.$limit.'">'.$i.' | </a></span>';
$start=$start+$limit;
}
?>
</td></tr>
<?php
}
?>
This code runs but, if you have any suggestions to make it more comprehensive, its really a big help.. thanks..
Anyone has example of pagination?
I have made but its very basic procedural.. Id like to make it functional
this is my code .. accept critics.. ..
if(isset($_GET['start']))
{
$start=$_GET['start'];
$limit=$_GET['limit'];
}
else
{
$start=0;
$limit=15;
}
$query="SELECT * FROM users LIMIT $start, $limit";
$queryall="SELECT * FROM users";
$result = dbquery($link,$query);
$resultall=dbquery($link,$queryall);
$numrows=mysql_num_rows($resultall);
if(mysql_num_rows($result) < 1 )
{
echo 'no results found';
}
else
{
echo $num = $row[0];
while($row=mysql_fetch_array($result))
{
<tr>
<td><? echo $row['username'] ?> </td>
<td><? echo $row[firstname] ?></td>
<td><? php echo $row[lastname] ?></td>
<td><?php echo $row[email] ?></td>
</tr>
<?php
}
<tr><td colspan="6" align="center" height="20" class="table-list-title"><b>Result Page </b>
<?
$numofpages=$numrows/$limit;
if(($numrows % $limit)!=0)
$numofpages=$numofpages+1;
for($i=1,$start=0;$i<=$numofpages;$i++)
{
echo '<span class="char"><A href="'; echo $_SERVER["PHP_SELF"]; echo '?click=userlist.php&start='.$start.'&limit='.$limit.'">'.$i.' | </a></span>';
$start=$start+$limit;
}
?>
</td></tr>
<?php
}
?>
This code runs but, if you have any suggestions to make it more comprehensive, its really a big help.. thanks..