I've spent the whole day digging for answers and none are simple enough for what I need to do. All I need to do is pass one number from one <select> routine to another.
Here's the code that will draw both fields:
$host="localhost";
$user="root";
$password="*type password here**";
$Dbname = "CallsToDispatch";
$cxn = mysql_connect($host,$user,$password)
or die (mysql_error() . "couldn’t connect to server");
mysql_select_db($Dbname, $cxn)
or die(mysql_error() . "couldn't select database");
echo '<form name="SystemForm" action="Retrieve.php" method="post" >';
echo '<select name="SystemNum" size="8" multiple="multiple" style="text-align:left;">';
echo '<option value = "0">All Systems In Texoma</option>';
$result = mysql_query("SELECT * FROM Systems ORDER BY LongSystem");
while($row = mysql_fetch_array($result))
{
$SystemNum = $row['SystemNum'];
echo '<option value = "' . $SystemNum . '">' . $row['LongSystem'] . '</option>';
}
echo '</select>';
// second box starts here
echo '<div class = "center" style="width:400px; margin:auto">';
echo '<select name="TechNum" size="8" multiple="multiple" style="text-align:left;">';
echo '<option value="0">All Techs in System</option>';
$result = mysql_query("SELECT * FROM Techs", $cxn);
$num_rows = mysql_num_rows($result);
if ($SystemNum == 67) $Quest = "SELECT * FROM Techs WHERE Contractor != ''";
else $Quest = "SELECT * FROM Techs WHERE SystemNum = '$SystemNum' ORDER BY '$TechNum'";
$result = mysql_query($Quest, $cxn)
or die ('Santa Claus is watching you' . mysql_error());
while ($row = mysql_fetch_array($result))
{
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$TechNum = $row['TechNum'];
echo '<option value = "' . $TechNum . '">' . $TechNum . '--' . $FirstName . ' ' . $LastName . '</option>';
}
echo '</select>';
echo '<br><br><input type="submit" value="Go" class = "FormButton" name = "Retrieve" style="font:24px Arial, Helvetica, sans-serif; font-weight:bold;">';
echo '</form>';
All I need is to pass the value of "SystemNum" to the second <select> field, which will then be populated with the techs that are in that "SystemNum". Also, I don't want the second <select> to appear until the user makes his selection of "SystemNum"