View Full Version: search

MPAM Rebooted Forums > Software support (freewares, PHP...) > search


Title: search


257335 - January 1, 2007 10:49 PM (GMT)
ok here is my code
CODE

<html>
<head>
<link rel="stylesheet" href="CSS.css" type="text/css" />
<title>Search Results</title>
</head>
<body>

<div id="sidebar">
<img src="images/bigdoglogo.gif" width="215"height="75">
<div id="menu">
<a href="Home.html">Home</a>
<a href="Apartments.php">Apartments</a>
<a href="Industrial.php">Industrial</a>
<a href="Land.php">Land</a>
<a href="Retail.php">Retail</a>
<a href="OfficeSpace.php">Office Space</a>
<a href="AboutUs.html">About Us</a>
<a href="CMS.php">Realtor login</a>
</div>
</div>
<div id="content">

</body>


<?php

if($_GET["city"])
$city=$_GET["city"];
else
$city='%';

if($_GET["state"])
$state=$_GET["state"];
else
$state='%';

if($_GET["zipcode"])
$zipcode=$_GET["zipcode"];
else
$zipcode='%';

if($_GET["pricemin"])
$pricemin=$_GET["pricemin"];

if($_GET["pricemax"])
$pricemax=$_GET["pricemax"];
else
$pricemax='%';

if($_GET["bathsmin"])
$bathsmin=$_GET["bathsmin"];

if($_GET["bathsmax"])
$bathsmax=$_GET["bathsmax"];
else
$bathsmax='%';

if($_GET["bedroomsmin"])
$bedroomsmin=$_GET["bedroomsmin"];

if($_GET["bedroomsmax"])
$bedroomsmax=$_GET["bedroomsmax"];
else
$bedroomsmax='%';

if($_GET["county"])
$county=$_GET["county"];
else
$county='%';

if($_GET["buyorlease"])
$buyorlease=$_GET["buyorlease"];
else
$buyorlease='%';

$con = mysql_connect("localhost","root","*****");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("realestate", $con);


$result = mysql_query("SELECT * FROM estate
WHERE city='".$city."'
AND state='".$state."'
AND zipcode='".$zipcode."'
AND price
BETWEEN '".$pricemin."' AND '".$pricemax."'
AND baths
BETWEEN '".$bathsmin."' AND '".$bathsmax."'
AND bedrooms
BETWEEN '".$bedroomsmin."' AND '".$bedroomsmax."'
AND county='".$county."'
AND buyorlease='".$buyorlease."'
");

while($row = mysql_fetch_array($result))
 {
echo "<table border='1'>
 <tr>
 <th>Address</th>
 <th>Price</th>
 <th>Baths</th>
 <th>Bedrooms</th>
 <th>State</th>
 <th>City</th>
 <th>Square Feet</th>
 <th>County</th>
 <th>Year Built</th>
 <th>Buy or Lease</th>
 </tr>";
 
 echo "<tr>";
 echo "<td>" . $row['address'] . "</td>";
 echo "<td>" . $row['price'] . "</td>";
 echo "<td>" . $row['baths'] . "</td>";
 echo "<td>" . $row['bedrooms'] . "</td>";
 echo "<td>" . $row['state'] . "</td>";
 echo "<td>" . $row['city'] . "</td>";
 echo "<td>" . $row['squarefeet'] . "</td>";
 echo "<td>" . $row['county'] . "</td>";
 echo "<td>" . $row['yearbuilt'] . "</td>";
 echo "<td>" . $row['buyorlease'] . "</td>";
 echo "</tr>";
 echo "</table>";
 

 }
if($result==0)
ECHO "<h3>NO MATCHES FOUND!</h3>";
mysql_close($con);


?>

</body>
</html>


as far as error go its working but i am having 2 problem
if no search results far found i want it to say that and its not
also i am trying to make it to where if nothing is entered in the form i want it to disregard that part of the form i tried to do this by using wildcards but this didn't work




Hosted for free by InvisionFree