welshart Posted December 8, 2009 Share Posted December 8, 2009 I retrieve two fields from a mysql table using the snippet below. The two values are incorporated into a list box. That works fine. The title is presented in the list box since this is the value that will make sense to the user but the unique ID for each record is written into the value for each list item. I would like the user to make their choice and based on that choice some data gets written back to the originating table. I can retreive the users choice of 'title' but I also need the 'id' value in order that I can write the data back to correct the originating row. How can PHP be used to source id? (value='$row->id') <?php foreach ($rows as $row) { echo "<option value='$row->id'>$row->title</option>"; } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/184448-retreive-list-box-value/ Share on other sites More sharing options...
mikesta707 Posted December 8, 2009 Share Posted December 8, 2009 if $row->id is the id, than simply doing $id = $_POST['Select_Form_Name'];//replace select form name with whatever your select is called should get the id that the user selected... I don't really see how you could get the title, the title isn't passed into the post variables, the value attribute is Quote Link to comment https://forums.phpfreaks.com/topic/184448-retreive-list-box-value/#findComment-973673 Share on other sites More sharing options...
welshart Posted December 8, 2009 Author Share Posted December 8, 2009 Thanks ever so much - I'm missing the obvious. much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/184448-retreive-list-box-value/#findComment-973731 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.