hi, i got the following php file as below, My database got 40 records, everything seems working but when i click the next button or [1][2][3] numbers like this on the page, it will change the url of the site
example:
[1] page: www.mysite.com/users.php
[2] page: www.mysite.com/users.php?start=10
[3] page: www.mysite.com/users.php?start=20
but showing the same record, it should show first 10 records and 2nd 10 records and so on.... please anybody help me to find out what I have done wrong with this coding.
Thank you very much.
PHP Code:<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Try Paging with php and mysql</title>
</head>
<body>
<?
include("database.php");
include "header.html";
$page_name="users.php";
if(!isset($start)) {
$start = 0;
}
$eu = ($start - 0);
$limit = 10;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
if (!$_GET[user])
{
$query2=" SELECT * FROM users ";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
echo <<<EOF
<table width="724" border="0" align="center">
<tr>
<td><table width="724" border="0" align="left" class="title">
<tr>
<td width="111"><div align="center">Username |</div></td>
<td width="104"><div align="center">Photo |</div></td>
<td width="75">Types |</td>
<td width="103"><div align="center">Nationality |</div></td>
<td width="125">Marital Staus |</td>
<td width="90">Children |</td>
<td width="86">Religion</td>
</tr>
</table></td>
</tr>
</table>
EOF;
$query=" SELECT * FROM users limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
while($user = mysql_fetch_array($result))
{
echo <<<EOF
<table width="724" border="0" align="center">
<tr>
<td><table width="724" border="0" align="left">
<tr>
<td>$user[id]</td>
<td width="111"><div align="center"><a href="users.php?user=$user[username]">$user[username]</a></div></td>
<td width="104"><div align="center"><a href="images/users/$user[pic]"><img src="images/users/$user[pic]" width="100"></a></div></td>
<td width="75"><div align="center">$user[types]</div></td>
<td width="103"><div align="center">$user[nationality]</div></td>
<td width="125">$user[marital_status]</td>
<td width="90">$user[children]</td>
<td width="86">$user[religion]</td>
</tr>
</table></td>
</tr>
</table>
EOF;
}
}
ELSE
{
$getuser = mysql_query("SELECT * from users where username = '$_GET[user]'");
$usernum = mysql_num_rows($getuser);
if ($usernum == 0)
{
echo ("<center>User Not Found</center>");
}
else
{
$profile = mysql_fetch_array($getuser);
echo <<<EOF
/* display user profile page with get */
EOF;
}
}
if($nume > $limit ){
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
if($back >=0) {
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
if($this1 < $nume) {
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";
}
include "footer.html";
?>
</body>
</html>





Bookmarks