BeanoEFC Posted December 22, 2009 Share Posted December 22, 2009 Hey Every1, I am trying to send a value submitted from a dynamic select list to a different page. However im running into problems. Here is my code for the 2 pages <html> <head> </head> <body> <form name="blah" method="post" action="selectlist3_1.php"> <select> <option>--Select Ride Destination--</option> <?php // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $query="select ride_name from ridedetails order by ride_name asc"; $result=mysql_query($query); while(list($ride_name)=mysql_fetch_row($result)) { echo "<option name='ride_name' value=" . $ride_name . ">" . $ride_name . "</option>"; } ?> </select> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> <html> <head> </head> <body> <?php $ride_name_post = $_POST['ride_name']; $ride_name_get = $_GET['ride_name']; echo "hello"; echo "<br>"; echo "Ride Name (get) : " . $ride_name_get; echo "<br>"; echo "Ride Name (post) : " . $ride_name_post; ?> </body> </html> I have been trying to duplicate the way i send values via a textfield by giving the <option> tag a name and and capturing the value by using $_POST['ride_name']. This is not working though. Any help would be appreciated. Regards, -Beano Quote Link to comment https://forums.phpfreaks.com/topic/186004-post-value-from-dynamic-select-list/ Share on other sites More sharing options...
cags Posted December 22, 2009 Share Posted December 22, 2009 The name attribute should be in the <select> tag rather than the <option> tag. Quote Link to comment https://forums.phpfreaks.com/topic/186004-post-value-from-dynamic-select-list/#findComment-982216 Share on other sites More sharing options...
nilambar Posted December 22, 2009 Share Posted December 22, 2009 Use name and id in select tag. this will solve your problem. Quote Link to comment https://forums.phpfreaks.com/topic/186004-post-value-from-dynamic-select-list/#findComment-982220 Share on other sites More sharing options...
BeanoEFC Posted December 22, 2009 Author Share Posted December 22, 2009 Thank You nilambar and cags =) Regards, -Beano Quote Link to comment https://forums.phpfreaks.com/topic/186004-post-value-from-dynamic-select-list/#findComment-982225 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.