Sorry, I´m not very good at making comments, I hope this will help.
<head><title>Search</title></head>
<body><h3>Search</h3>
<center><table border=0 cellspacing=0 width=100%><tr>
<td height=12 align=left width=50%>
<form method=get action="<?php print("$PHP_SELF"); ?>">
<input type=text name="Search">
<input type=submit value=Search></center>
</td></tr></table></form>
<?php
//connect to database
$connection = mysql_connect("localhost","user","psw") or die("can´t establish connection");
$db = mysql_select_db("db",$connection);
//returns the query
$max = 0;
$bmax = mysql_query("SELECT * FROM table WHERE name like '%$search%' OR city like '%$search%'");
while ($result = mysql_fetch_array($bmax))
$max++;
//returns number of rows in the query
$maxresult = 10;
$sql_text = ("SELECT * FROM table WHERE name like '%$search%' OR like '%$search%'");
$query = mysql_query($sql_text);
//sorts rows 10/page
$page=mysql_num_rows($query);
if ($page)
$page = 1;
$backpage = $page - 1;
$nextpage = $page + 1;
$start = ($maxresult * $page) - $maxresult;
$num_rows = mysql_num_rows($query);
if ($num_rows <= $maxresult)
$num_pages = 1;
elseif (($num_rows % $maxresult) == 0)
$num_pages = ($num_rows / $maxresult);
else
$num_pages = ($num_rows / $maxresult) + 1;
$num_pages = (int) $num_pages;
if (($page > $num_pages) || ($page < 0))
$sql_text = $sql_text . " LIMIT $start, $maxresult";
if ($max>$maxresult)
echo "<center>";
//returns the previous page´s results
if ($backpage)
echo "<a href=\"search.php?search=$search&page=$backpage\">Prev</a>";
else
echo "Prev";
for ($i = 1; $i <= $num_pages; $i++)
if ($i != $page)
echo "<a href=\"search.php?search=$search&page=$i\">$i</a> ";
else
echo " $i ";
//returns the next page´s results
if ($page != $num_pages)
echo "<a href=\"search.php?search=$search&page=$nextpage\">Next</a>";
else
echo "Next";
echo "</center>";
//
echo "<table border=0 cellspacing=0 width=100%>";
//
$a = $start + 1;
while ($result = mysql_fetch_array($query))
echo"<tr><td height=12 align=left width=70%>";
//prints results Id, city name
print($a. $result['Id']);
print("</a></td><td align=\ right>");
print($result['city']);
print($result['name']);
print("</a>");
$a++;
echo "</td> </tr> <tr>";
echo "<td colspan=2>";
echo " </td></tr>";
echo "</table>";
if ($max>$maxresult)
echo "<br><br><br><center>";
if ($backpage)
echo "<a href=\"search.php?search=$etsi&page=$backpage\">Prev</a>";
else
echo "Prev";
for ($i = 1; $i <= $num_pages; $i++)
if ($i != $page)
echo " <a href=\"search.php?search=$search&page=$i\">$i</a> ";
else
echo " $i ";
if ($page != $num_pages)
echo "<a href=\"search.php?search=$search&page=$nextpage\">Next</a>";
else
echo "Next";
echo "</center>";
?>
</body>