Forum Moderators: coopster
when you submit
Hotel: Crown Reef
Myrtle Beach Area: North Strand
it gives you this on the ouraction.php page
select * from hotels where value=crown reef and value='north strand'
----------------------------
-----html for search------
----------------------------
<html>
<head>
<title>Search Hotels</title>
</head>
<body>
<form name="form1" method="POST" action="ouraction.php">
<p> Hotel Name: <input name="name" type="text" id="name"><p>
<SELECT NAME="myrtlebeacharea">
<OPTION VALUE="ns">North Strand
<OPTION VALUE="mb">Myrtle Beach
<OPTION VALUE="ss">South Strand
</SELECT>
<SELECT NAME="city">
<OPTION VALUE="cherygrove">Cherry Grove
<OPTION VALUE="northmb">North Myrtle Beach
<OPTION VALUE="myrtlebeach">Myrtle Beach
<OPTION VALUE="surfside">Surfside Beach
<OPTION VALUE="gardencity">Garden City
</SELECT>
<p><input type="submit" name="submit" value="submit">
</form>
</body>
</html>
--------------------------------------
------php script to search----------
--------------------------------------
<?
$host = "mysql-host";
$user = "mysql-username";
$pass = "mysql-password";
$dbname = "hotellist";
$connection = mysql_connect(mysql-host,mysql-username,mysql-password) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$sql = "select * from hotels where id=" . $_POST['name'] . " and id='" . $_POST['myrtlebeacharea'] . "'";
echo $sql;
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<p>",$row['name'],": ",$row['myrtlebeacharea'];
}
?>
--------------------------------------------
I would like to add more fields to like
$_POST['address']
$_POST['city']
$_POST['website']
etc....
any help with this would be appreciated thanks
Steve
[edited by: coopster at 2:52 pm (utc) on Nov. 8, 2005]
[edit reason] removed unnecessary code and urls [/edit]
you could start with this thread about Developing a MySQL search query [webmasterworld.com] from our PHP library [webmasterworld.com].
see if that gives some explanation and then we can go from there.