I am trying to make all rows selected show up in a HTML table.
here is the code that I have....
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
mysql_connect("localhost","username","password");
mysql_select_db("gatorw56_homesearch");
$search=$_GET["models,bed,bath,garage,price,dwelling"];
$sql = "SELECT * FROM homes WHERE models LIKE '%$search%'";
if ($_POST['bed'] != "any") {
$sql .= " AND bed = '".$bed."'";
}
if ($_POST['bath'] != "any") {
$sql .= " AND bath = '".$bath."'";
}
if ($_POST['garage'] != "any") {
$sql .= " AND garage = '".$garage."'";
}
$price_upper_bound = $_POST['price'];
switch($price_upper_bound) {
case "any":
$range = "";
break;
case "0":
$range = " AND (price >= 0) AND (price <= 50000)";
break;
case "1":
$range = " AND (price > 50000) AND (price <= 150000)";
break;
case "2":
$range = " AND (price > 150000) AND (price <= 200000)";
break;
case "3":
$range = " AND (price > 200000) AND (price <= 250000)";
break;
case "4":
$range = " AND (price > 250000) AND (price <= 300000)";
break;
default:
$range = "";
}
$sql .= $range;
$result = @($sql)
or die("<p>Couldn't execute query: <strong>".mysql_error()."</strong></p>");
while($r=mysql_fetch_array($result))
{
$models=$r["models"];
$bed=$r["bed"];
$bath=$r["bath"];
$garage=$r["garage"];
$sqft=$r["sqft"];
$price=$r["price"];
$dwelling=$r["dwelling"];
$price = number_format($price);
$sqft = number_format($sqft);
}
?>
<table width="300" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF">
<tr>
<td>Models: <? echo"$models"; ?><br>Bed/Bath/Garage: <? echo"$bed / $bath / $garage"; ?><br>Sqft: <? echo"$sqft"; ?><br>Price: <? echo"$$price"; ?><br>Dwelling: <? echo"$dwelling"; ?></td>
</tr>
</table>
</body>
</html>
I am having a problem of showing results in a HTML table. It only shows one row pulled when there should be a total of four showing.
How do I make it show all the rows?
should I putting the fetch array somewhere else or what?
here is what happens if you want to see it in action....
http://www.gatorwire.com/play/
just click submit with all options selecting any. It should be showing all four rows but only one is showing.