Hi and thanks for your help,
Ii thought if I add the code it might be more clear what I am 'trying' to do.
I have a form that uses the value of 'builderid' passed to it to grab a set of community names for that builder fro the DB. Once a community name is selected, a set of house types for that community is then selected from the DB. These are all used to populate a set of two drop downs (community and house types drop downs.)
It works fine until I select a value from the community drop down. Then in response to onChange of dropdown, it submitss to PHP-SELF, but with no builderid=<some builder id> and the result is a blank page.
<?php
include ('item_sc_fns.php');
@ $builderid = $_GET['builderid'];
// query database for a list of builders
$conn = db_connect();
$queryB = "SELECT BuilderName FROM Builders WHERE BuilderID=$builderid";
$resultB = @mysql_query($queryB);
// $resultB = db_result_to_array($resultB);
$num_builders = @mysql_num_rows($resultB);
$builder = mysql_result($resultB, 0, 'BuilderName');
$queryD = "SELECT * FROM Developments WHERE BuilderID =$builderid";
$resultD = mysql_query($queryD);
$num_devs = @mysql_num_rows($resultD);
$resultD = db_result_to_array($resultD);
?>
(in another file, inculded in the form)
function db_result_to_array($result)
{
$res_array = array();
for ($count=0; $row = @mysql_fetch_array($result); $count++)
$res_array[$count] = $row;
return $res_array;
}
<form name="info_form" method="post" action="<? $_SERVER['PHP_SELF'] ?>" >
<table width="100%">
<tr>
<td>Builder</td>
<td><input name="Builder" type="text" value="<?php echo $builder ?>" readonly="true">
</td>
</tr>
<tr>
<td>Community</td>
<td><select name="Development" onChange="submit()">
<?php
if (!is_array($resultD)){
echo '<option>No developments currently available</option></select>';
return;
}
echo '<option selected="selected">- Select a Community -</option>';
foreach ($resultD as $row){
echo '<option value="';
echo $row['DevID'];
echo '">';
echo $row['DevName'];
echo "</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>House Type</td>
<td><select name="selectedHT">
<?php
$resultHT = mysql_query("SELECT * FROM HouseTypes WHERE DevID=$Development");
$resultHT = mysql_query($queryHT);
$num_ht = @mysql_num_rows($resultHT);
$resultHT = db_result_to_array($resultHT);
if (!is_array($resultHT)){
echo '<option>No House Types currently available</option></select>';
return;
}
echo '<option selected="selected">- House Type options will appear here -</option>';
foreach ($resultHT as $row){
echo '<option value="';
echo $row['HouseTypeID'];
echo '">';
echo $row['HTName'];
echo "</option>\n";
}
?>
</select>
</td>
</tr>
</table>
</form>