gple Posted March 25, 2007 Share Posted March 25, 2007 I have a drop down menu and I want to insert the selection from the drop down menu into the database. How would I go about this? Link to comment https://forums.phpfreaks.com/topic/44183-option-value/ Share on other sites More sharing options...
Steve Angelis Posted March 25, 2007 Share Posted March 25, 2007 Set the value of each item to a specific thing, then on your posting page get it to grab that item, and store it in the database. To retreave it, use either the case or if statements and use it with "selected". Link to comment https://forums.phpfreaks.com/topic/44183-option-value/#findComment-214565 Share on other sites More sharing options...
AndyB Posted March 25, 2007 Share Posted March 25, 2007 @steve - that may be rather too cryptic for gple. <form action="nextpage.php" method="post"> <select name="something"> <option value="banana">banana</option> <option value="lemon">lemon</option> </select> <input type="submit" value="pick a fruit"/> </form> <?php // nextpage.php $fruit = $_POST['something']; // retrieve POSTed value from form .. establish database connection .. select database $query = "INSERT into table_name .... "; // create your query string $result = mysql_query($query); // execute query ?> Link to comment https://forums.phpfreaks.com/topic/44183-option-value/#findComment-214728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.