Wouldn't a little javascript solve this problem??
Have your first dropdown menu, then when an option is selected use a
javascript Onchange function to refresh (post) the page to itself. This
would set the selected option as your "form1" value. Then just write a
simple query using that value to return the options you want for dropdown
#2.
Something like this:
<select name="states" onchange="this.submit();">
<option value="AL" > Alabama
<option value="FL" >Florida
<option value="WA" >Washington
<option value="MI" >Michigan
</select>
if (!isset($_POST['submit'])) {
$state = $_POST['states'];
Then put your result in an array and populate your second dropdown.
<td width="43" align="right">City:</td>
<td width="135" align="left" class="tblcell_sm">
<SELECT name="city">
<?php
$database = mssql_select_db("database", $connection) or die ('DB selection
failed');
// Query the table and load all of the records into an array.
$q_cities = "SELECT * FROM cities WHERE state_name = '$state'";
$r_cities = mssql_query($q_cities) or die(mssql_error());
while ($rec_cities = mssql_fetch_assoc($r_cities)) $c_city[] =
$rec_cities;
echo "<OPTION value=\"\">--SELECT--</OPTION>\n";
foreach ($c_city as $s_city)
{
if ($s_city['state_name'] == $_POST['states'])
echo "<OPTION value=\"{$s_city['city_code']}\"
SELECTED>{$s_city['city_name']}</OPTION>\n";
else
echo "<OPTION
value=\"{$s_city['city_code']}\">{$s_cc['city_name']}</OPTION>\n";
}
?>
</SELECT>
</td>
Hope that helps?? lol
On 6/12/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
BSumrall wrote:
> It doesn't like the curly brackets either!
>
> Brad
>
if this is within PHP, the '{' and '}' are within double quotes (which
they seem to be),
These examples should all do the same thing.
$query_Recordset1 = "SELECT * FROM lstng_tbl WHERE price_range =
'$select1'";
$query_Recordset1 = "SELECT * FROM lstng_tbl WHERE price_range =
'{$select1}'";
$query_Recordset1 = "SELECT * FROM lstng_tbl WHERE price_range =
'".$select1."'";
echo $query_Recordset1;
place an echo just after including the variable and see if you see the
brackets in the statement.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php