Copy link to clipboard
Copied
I've got an application I'm working on, and I am trying to set up an update record page. The problem I'm having is getting the initial value to display. How do I get the drop down box to display the initial value that is in located in one table of the database, but have the rest of the values of the drop down box pull values from another table in the database?
The code that I've got for the drop down box now is;
<select name=\"rating\">\n";
$query="SELECT * from rating";
$result=mysql_query($query);
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
$rating_id = $row['rating_id'];
$rating_name = $row['rating_name'];
$rating_abv = $row['rating_abv'];
echo "<option value=\"$rating_abv\"> $rating_name </option>\n";
}
echo "</select>
The dropdown box I've got now works just fine, but does not have an initial value corresponding with the record I'm updating. When I add a variable to the first line to read:
<select name=\"rating\" value=\"$rating\">\n";
with $rating defined as the variable pulled from the table I want the initial value to be set at, nothing happons. Any help would be greatly appreciated.
Copy link to clipboard
Copied
To make dynamic drop down menu, first you need to create recordset for it. Assuming the recordset name is 'getRecord'. When u insert the drop down menu, click it and at properties, choose Dynamic button. At the "option from Recordset" field, choose the previous 'getRecord', Values > what the value to store and Labels > what u want to list in drop down menu. If u are setting for update, at "Select value equal to" field, click at small 'lightning' button and choose the value from recordset which is suppose to be updated.
Copy link to clipboard
Copied
I figured it out. Change the select statement to this:
<select name=\"rating\">\n";
$queryb="SELECT * from rating";
$resultb=mysql_query($queryb);
while($row=mysql_fetch_array($resultb,MYSQL_ASSOC))
{
$temp_name = $row['rating_name'];
$name = $row['rating_abv'];
if ($name == $rating)
echo "<option value=\"$name\" selected=\"selected\"> $temp_name </option>\n";
else
echo "<option value=\"$name\"> $temp_name </option>";
}
echo "</select>
with the variable $rating defined in the table you want the initial value to be set to (this query gets the values from the other table to populate the rest of the drop down box), and it works just perfectly.
Copy link to clipboard
Copied
Marking as assumed answered.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now