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 Link to comment https://forums.phpfreaks.com/topic/106159-solved-listmenu-value-to-variable/ Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 Can you post your code? Link to comment https://forums.phpfreaks.com/topic/106159-solved-listmenu-value-to-variable/#findComment-544135 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> Link to comment https://forums.phpfreaks.com/topic/106159-solved-listmenu-value-to-variable/#findComment-544187 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']; } ?> Link to comment https://forums.phpfreaks.com/topic/106159-solved-listmenu-value-to-variable/#findComment-544190 Share on other sites More sharing options...
biggieuk Posted May 18, 2008 Author Share Posted May 18, 2008 thanks, that worked great. Link to comment https://forums.phpfreaks.com/topic/106159-solved-listmenu-value-to-variable/#findComment-544213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.