i have a pretty simple problem, but i cant figure it out.... i have a search utility that goes through a table and then displays the matching results in a simple table on another page (with pagination if the search returns more than 10 results).... the search works fine as does the pagination, its the table that is giving me problems
the table will show the results with each record having its own row......comprising of one cell with the name, city, address, province, postal code and phone numbers and another cell with a (sometimes long) description of the business/organization.... this works just fine, except when it comes to the last record in each search.... the links (next, back and "search again") are always displayed above the last returned item in the table.... like so:
Test Organization 2
456 Any Street
Prince Albert, SK
S4S5P2
3063333333
3063333333
Search Again this is the link that is out of place that im talking about
Test Organization 2
456 Any Street
Prince Albert, SK
S4S5P2
3063333333
3063333333
so everything is working right, but the layout isnt working for some reason.... i have attached my code below in the hopes that somebody can point out what i am missing.... thx in advance
<?
include("other.inc");
$connection = mysql_connect($host,$user,$password)or die ("couldn’t connect to server");
$db = mysql_select_db($database,$connection)or die ("Couldn’t select database");
//check if this is the first page
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow']))
{
//we give the value of the first row to 0
$startrow = 0;
}
//otherwise we take the value from the URL
else
{
$startrow = (int)$_GET['startrow'];
}
$query = "SELECT * FROM houses_temp where houseID like '%%'";
$result = mysql_query($query) or die (mysql_error($connection));
$numrows_total = mysql_num_rows($result);
$query .= "LIMIT $startrow, 10";
//below is the table layout for results
$result2 = mysql_query($query) or die (mysql_error($connection));
$numrows = mysql_num_rows($result2);
while ($row = mysql_fetch_array($result2,MYSQL_ASSOC))
{
extract($row);
echo "<table width='50%' border='0' cellpadding='0'>";
echo "<tr><td width='25%'>$name<br>$address<br>$city,
$province<br>$postalCode<br>$phoneNum
<br>$altPhoneNum</td>";
echo "<td valign='top' width='25%'>$description</td></tr>";
echo "<hr>";
}
if ($numrows == 0)
{
echo "<b>There were no matches found for your search.</b>";
echo "<form name='search' action='search_redirect.php' method='post'>";
echo "Enter your search criteria:<br>";
echo "<input type='text' name='criteria'><br>";
echo "<input type='submit' name='search' value='Search'>";
echo "</form>";
exit;
}
//now these are the links
if (($startrow>=10))
{
echo '<a href="show_search.php?startrow='.($startrow-10).'">Back</a>';
echo '   ';
}
if (($numrows_total>10) and ($numrows>=10))
{
echo '<a href="show_search.php?startrow='.($startrow+10).'">Next</a>';
}
echo "<br>";
echo '<a href="search.php">Search Again</a>';
?>