display php search results in html table
<p>im running this php script and not quite getting the result i want. at the moment its giving me this output</p>

<pre><code>scuba tank

mike

0.00
450.00
5.00

2012-06-04 18:50:22


scuba tank

liam

80.00
350.00
2.50

2012-06-04 19:00:09

Displaying 3 results

scuba tank

josh

410.00
0.00
5.00

2012-06-04 19:00:09
</code></pre>

<p>its pretty much what i want except the line displaying 3 results should be displayed at the end instead of before the last entry. what do i need to do to my script to fix this?</p>

<pre><code>&lt;?php

$host = "localhost";
$user = "root";
$pass = null;

// ========================================
$dbhost = @mysql_connect($host, $user, $pass) or die("Unable to connect to server");

@mysql_select_db("divebay") or die("Unable to select database");

$var = "scuba";
$query = trim($var);

if(!isset($query)){
echo "Your search was invalid";
exit;
} //line 18

$sql = "SELECT * FROM auction WHERE name LIKE '%" . $query . "%'";

$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
mysql_close($dbhost);

if($numrows == 0){
echo "Sorry, your search did not return any results";
}

$i = 0;

while($i &lt; $numrows){
$row = mysql_fetch_array($result);

$ID = $row['ID'];
$name = $row['name'];
$owner = $row['owner'];
$holder = $row['holder'];
$start = $row['sprice'];
$current = $row['cprice'];
$instant = $row['iprice'];
$inc = $row['incprice'];
$image = $row['img'];
$time = $row['stime'];
$length = $row['duration'];

echo "
&lt;?xml version = '1.0' encoding = 'utf-8'?&gt;
&lt;!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org    /TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
&lt;html xmlns='http://www.w3.org/1999/xhtml'&gt;

&lt;head&gt;
&lt;title&gt;searchdbresults&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;  
&lt;table style='width = 800px;'&gt;
&lt;tr style ='height = 200px;'&gt;
&lt;td style ='width = 200px;'&gt;&lt;/td&gt;
&lt;td style ='width = 300px;'&gt;
&lt;div style ='180px'&gt; $name &lt;/div&gt;
&lt;div&gt; $owner &lt;/div&gt;
&lt;/td&gt;
&lt;td style='width =200px'&gt;
&lt;div style='height = 100px'&gt; $current &lt;/div&gt;
&lt;div style='height = 50px'&gt; $instant &lt;/div&gt;
&lt;div&gt; $inc &lt;/div&gt;
&lt;/td&gt;
&lt;td&gt; $time &lt;/td&gt;
&lt;/tr&gt;";

$i++;   
}


echo "
&lt;tr&gt; Displaying $numrows results&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;";
?&gt;
</code></pre>
