Page 1 of 1

List menu Help?

Posted: Sun Jul 14, 2002 9:43 pm
by rayfusion
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 ::

Posted: Mon Jul 15, 2002 12:02 am
by ajaypatil
What have you tried so far ?

Ajay

Posted: Mon Jul 15, 2002 5:41 am
by rayfusion
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>

Posted: Mon Jul 15, 2002 9:46 pm
by ajaypatil
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

Code: Select all

<option value="<?php echo $row_rs_modify&#1111;'tech_group']?>"<?php if (!(strcmp($row_rs_modify&#1111;'tech_group'], $row_rs_modify&#1111;'tech_group']))) &#123;echo "SELECTED";&#125; ?>><?php echo $row_rs_modify&#1111;'tech_group']?></option>
should be something like:

Code: Select all

<option value="<?php echo $row_rs_modify&#1111;'tech_group']?>"
  <?php if ($row_rs_modify&#1111;'tech_group'] == $current_tech_group) 
            &#123;echo "SELECTED";&#125; ?>
><?php echo $row_rs_modify&#1111;'tech_group']?></option>
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