Hello. I am stuck with a search that will query two database tables to get values for 'price' and 'area' and populate two dropdowns. Then the action.php will use the price/area values to display records from a table called 'list'.
When I click search I get a section of code from the action.php file. Any help would be great, thanks. Here is the code:
first php page including search form:
<?php
require_once ('mysql_connect.php');
$query = "SELECT * FROM price, area";
$result = @mysql_query ($query);
$pulldown = '<option>Select One</option>';
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
$pulldown .= "<option value=\"{$row['priceband_id']}\">{$row['priceband']}</option>\n";
$pulldown2 = '<option>Select One</option>';
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
$pulldown2 .= "<option value=\"{$row['area_id']}\">{$row['area']}</option>\n";
}
?>
<form method="get" action="action.php"> Price<select name="priceband">
<?php echo $pulldown; ?>
</select><br />
Area<select name="area">
<?php echo $pulldown2; ?>
</select>
<p><input type="submit" name="submit" value="submit" />
</form>
action.php:
<?php
$sql = "SELECT * FROM list WHERE price=" . $_get['price'] . " AND area=' . $_get['area'] . '";
echo $sql;
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<p>",$row['price'],": ",$row['area'];
}
?>