I've just created a search form where I can search through drop down boxes for results in a database however I need to know how to access the whole result set from one specific option in the dropdown box . This is the form
<?php
require_once("bookmark_fns.php");
do_html_header("Search Page");
?>
<form method=post action="formoutput2.php">
<table bgcolor=#cccccc >
<tr>
<td colspan=2>Search For a Property:</td>
<tr>
<td>Suburb:</td>
<td><select type=name name=resultset>
<Option value="All suburbs">All Suburbs
<Option value="charlestown">Charlestown
<Option value="dudley">Dudley
<Option value="newcastle">Newcastle
<Option value="redhead">Redhead
<Option value="kahibah">Kahibah
</td></tr>
<tr>
<td colspan=2 align=center>
<input type=submit value=Search></td></tr>
?>
Now i just wanna access the whole results set in the database by someone picking 'all suburbs' but at the same time if anyone picks a specific suburb they will get the results relating to that suburb only. Heres the backend and output(yes Iknow its unformatted and ugly)
<?
$username="xxxx";
$password="xxxx";
$database="xxxx";
mysql_connect(localhost,$xxx,$xxxxx);
@mysql_select_db(xxxx) or die( "Unable to select database");
$query="SELECT * FROM realestate WHERE suburb='$resultset' ";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Your Properties</center></b><br><br>";
echo "<B><p>Number of properties found: ".$num."</B></p>";
echo '<TABLE bgcolor=#ccccccc>';
echo '<TR><TH>Suburb</TH><TH>Address</TH><TH>Price</TH><TH>Property Details</TH></TR>';
while ( $row = mysql_fetch_array( $result ) )
{
echo '<TR>';
echo '<TD>' . htmlspecialchars( stripslashes( $row['suburb'] ) ) . '</TD>';
echo '<TD>' . htmlspecialchars( stripslashes( $row['address'] ) ) . '</TD>';
echo '<TD>' . htmlspecialchars( stripslashes( $row['price'] ) ) . '</TD>';
echo '<TD>' . htmlspecialchars( stripslashes( $row['property'] ) ) . '</TD>';
echo '</TR>';
}
echo '</TABLE>';
?>
Someone help please. thanks in advance