Jump to content

[SOLVED] Listmenu value to variable


biggieuk

Recommended Posts

Hi,

 

Im having trouble assigning the value of a listmenu item to a variable.

 

the listmenu is populated dynamically from a database using 'username' as the label and 'email' as the value.

 

I need to assign the 'email' value of the selected item to a variable.

 

Can anybody please give me some guidance.

 

Thanks

Link to comment
Share on other sites

Your not going to like it, i used Dreamweaver to dynamically populate the listmenu  ::)

 

<select name="select2" id="select2" disabled = "disabled">
    <?php
do {  
?>
    <option value="<?php echo $row_users['email']?>"<?php if (!(strcmp($row_users['email'], $row_users['email']))) {echo "selected=\"selected\"";} ?>><?php echo $row_users['username']?></option>
    <?php
} while ($row_users = mysql_fetch_assoc($users));
  $rows = mysql_num_rows($users);
  if($rows > 0) {
      mysql_data_seek($users, 0);
  $row_users = mysql_fetch_assoc($users);
  }
?>
  </select>

Link to comment
Share on other sites

Obviously your axpecting more than one email? If so, you'll need to store them in an array. eg;

 

<?php
do {  
?>
    <option value="<?php echo $row_users['email']?>"<?php if (!(strcmp($row_users['email'], $row_users['email']))) {echo "selected=\"selected\"";} ?>><?php echo $row_users['username']?></option>
    <?php
} while ($row_users = mysql_fetch_assoc($users));
  $rows = mysql_num_rows($users);
  if($rows > 0) {
      mysql_data_seek($users, 0);
      $row_users = mysql_fetch_assoc($users);
      $emails[] = $row_users['email'];
  }
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.