I am trying to make a PHP script that searches a database and you can press "next page" and "previous page" and have a limit to 10 results per page.
So far i have:
Code: Select all
<?php
mysql_connect ('localhost', 'username', 'password') ;
mysql_select_db ('users');
$sql = "SELECT * FROM users ORDER BY id ASC LIMIT ".$limit.",10";
$result = mysql_query($sql) or
print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error());
while ($row = mysql_fetch_array($result))
{
$username = $rowї"username"];
$email = $rowї"email"];
$id = $rowї"id"];
print "<table width=250 border=1 cellspacing=0 cellpadding=0>";
print "<tr>";
print "<td width=3>'$id'</td>";
print "<td width=247>'$username'</td>";
print "</tr>";
print "<tr>";
print "<td colspan=250>'$email'</td>";
print "</tr>";
print "</table><br><br>";
}
?>
<a href="users.php?limit=0,10">last 10 results</a>
<a href="users.php?limit=20,10">next 10 results</a>David