biggieuk Posted May 18, 2008 Share Posted May 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 Can you post your code? Quote Link to comment Share on other sites More sharing options...
biggieuk Posted May 18, 2008 Author Share Posted May 18, 2008 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> Quote Link to comment Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 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']; } ?> Quote Link to comment Share on other sites More sharing options...
biggieuk Posted May 18, 2008 Author Share Posted May 18, 2008 thanks, that worked great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.