[solved] wildcard use maybe?
Posted: Wed Sep 14, 2005 1:56 pm
Hi,
I have a search form for my db - I have various option values for my drop down list. I can get the search to work on teh db when i select from the options however I want at the top of the list a value "All" which will list all.
Currently I am trying to use a wildcard but it doesnt work! Any ideas? Thanks
(also as a side - I need it to list more than one if there is more than one result !!)
I have a search form for my db - I have various option values for my drop down list. I can get the search to work on teh db when i select from the options however I want at the top of the list a value "All" which will list all.
Currently I am trying to use a wildcard but it doesnt work! Any ideas? Thanks
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>Car Test - User Quick Search</p>
<form enctype="multipart/form-data" method="post" action="<?php echo $PHP_SELF ?>">
<p>Location
<select name="location_subarea" size="1">
<option value="*">ALL</option>
<option value="South East - London">South East - London</option>
<option value="North West - Manchester">North West - Manchester</option>
<option value="South East - Kent">South East - Kent</option>
</select>
</p>
<p>Price Range
<select name="car_pbracket" size="1">
<option value="*">ALL</option>
<option value="0-500">0-500</option>
<option value="500-1000">500-1000</option>
<option value="1000-1500">1000-1500</option>
</select>
<br>
<input type="submit" name="submit" value="Search">
</p>
</form>
<p> </p>Code: Select all
<?php
if ($submit) {
$username="xxxx_xxxx";
$password="xxxx";
$database="xxxx_xxxx";
$location_subarea=$_POST['location_subarea'];
$car_pbracket=$_POST['car_pbracket'];
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query("SELECT * FROM newsstuf_usedcars
WHERE location_subarea='$location_subarea' AND car_pbracket='$car_pbracket'") or die(mysql_error());
$row = mysql_fetch_array( $result );
echo $query;
echo( "<a href=\"editdetails.php?id=".$row['id']."\">".$row['id']." . ".$row['contact_nfirst']." ".$row['contact_nlast']." - ".$row['car_make']."</a><br />" );
}
mysql_close();
?>
</body>
</html>