I am pulling a record into a form so I could modify that record. One of the fields in the form is a List Menu. I want to pull the value of the List Menu for that record as the selected value. I also want to have all of the other options in the List Menu available for me to choose if needed. Thanks in advance.
::rayfusion---> t = everlasting life ::
List menu Help?
Moderator: General Moderators
Here is the code so far....
<select name="tech_group" id="tech_group" title="<?php echo $row_rsChoose_Tech_Group['tech_group']; ?>">
<?php
do {
?>
<option value="<?php echo $row_rs_modify['tech_group']?>"<?php if (!(strcmp($row_rs_modify['tech_group'], $row_rs_modify['tech_group']))) {echo "SELECTED";} ?>><?php echo $row_rs_modify['tech_group']?></option>
<?php
} while ($row_rs_modify = mysql_fetch_assoc($rs_modify));
$rows = mysql_num_rows($rs_modify);
if($rows > 0) {
mysql_data_seek($rs_modify, 0);
$row_rs_modify = mysql_fetch_assoc($rs_modify);
}
?>
</select>
<select name="tech_group" id="tech_group" title="<?php echo $row_rsChoose_Tech_Group['tech_group']; ?>">
<?php
do {
?>
<option value="<?php echo $row_rs_modify['tech_group']?>"<?php if (!(strcmp($row_rs_modify['tech_group'], $row_rs_modify['tech_group']))) {echo "SELECTED";} ?>><?php echo $row_rs_modify['tech_group']?></option>
<?php
} while ($row_rs_modify = mysql_fetch_assoc($rs_modify));
$rows = mysql_num_rows($rs_modify);
if($rows > 0) {
mysql_data_seek($rs_modify, 0);
$row_rs_modify = mysql_fetch_assoc($rs_modify);
}
?>
</select>
Hi,
You seem to be proceeding in right direction.
I have the following suggestions:
a) The names $rs_modify and $row_rs_modify are very confusing.
Is this the list of all records in tech group table.
If yes, then $rs_tech_group is more meaningful.
b) As I understand, you want to show the current value in form
as selected in the list menu.
If so, then you should read the current value in form into a
variable like $current_tech_group and then compare against
each value in the list menu.
Your code
should be something like:
If you still have some problems, please paste your entire code
including the queries to select the form record and the list menu values.
Ajay
You seem to be proceeding in right direction.
I have the following suggestions:
a) The names $rs_modify and $row_rs_modify are very confusing.
Is this the list of all records in tech group table.
If yes, then $rs_tech_group is more meaningful.
b) As I understand, you want to show the current value in form
as selected in the list menu.
If so, then you should read the current value in form into a
variable like $current_tech_group and then compare against
each value in the list menu.
Your code
Code: Select all
<option value="<?php echo $row_rs_modifyї'tech_group']?>"<?php if (!(strcmp($row_rs_modifyї'tech_group'], $row_rs_modifyї'tech_group']))) {echo "SELECTED";} ?>><?php echo $row_rs_modifyї'tech_group']?></option>Code: Select all
<option value="<?php echo $row_rs_modifyї'tech_group']?>"
<?php if ($row_rs_modifyї'tech_group'] == $current_tech_group)
{echo "SELECTED";} ?>
><?php echo $row_rs_modifyї'tech_group']?></option>including the queries to select the form record and the list menu values.
Ajay