Select box - Update Form
Posted: Tue Apr 12, 2005 4:17 pm
Hi,
I’m trying to return a value to a ‘select box’ in an ‘Update Form’ that has been previously stored in a field in my MSQL database. The bit of code I’m using is this:
Basically the ‘Form’ that initially passes this information is dynamically populated with a list of locations such as:
Cork town
Cork
Cork city
What I want to do is have the data that has been originally sent to the database returned to my Update Form with the specific selected value displayed in the select box but at the same time once the accompanying dropdown box is clicked will still reveal all the other data.
At the moment I’m getting this returned to the browser using the code above: http://ahamay.com/select.htm I think that my problem is to do with the use of ‘;’ etc but I’m really only at this PHP stuff since Christmas and struggle with the little things!
Thanks a mil for any help
I’m trying to return a value to a ‘select box’ in an ‘Update Form’ that has been previously stored in a field in my MSQL database. The bit of code I’m using is this:
Code: Select all
mysql_select_db($database_imtdatabase, $imtdatabase);
$query_rstSearchLocations = "SELECT * FROM locations ORDER BY Counties_IDPK ASC";
$rstSearchLocations = mysql_query($query_rstSearchLocations, $imtdatabase) or die(mysql_error());
$totalRows_rstSearchLocations = mysql_num_rows($rstSearchLocations);
<?php $strSavedValue = $row_getUpdateDetails['LocationList'];
echo "<select name='LocationList' id='LocationList'>\n";
while($dbRow = mysql_fetch_array($rstSearchLocations)){
echo "<option value='" . $dbRow["Counties_IDPK"]."'>";
if ($dbRow["Counties_IDPK"] == $strSavedValue){
echo 'Previous Selected'; // to be removed
echo $dbRow["Counties_Name"]."</option>\n";
} echo "</select>\n";
}?>Cork town
Cork
Cork city
What I want to do is have the data that has been originally sent to the database returned to my Update Form with the specific selected value displayed in the select box but at the same time once the accompanying dropdown box is clicked will still reveal all the other data.
At the moment I’m getting this returned to the browser using the code above: http://ahamay.com/select.htm I think that my problem is to do with the use of ‘;’ etc but I’m really only at this PHP stuff since Christmas and struggle with the little things!
Thanks a mil for any help