desiinusa123 Posted September 3, 2008 Share Posted September 3, 2008 Hi I am newbie here...I am new to php. i HAVE A QUESTION REG THIS DROP DOWN, which is in .html and while action takes place it takes me to process1.php .HTML CODE students: <label> <select name="students" size="1" id="students"> <option value="Freshman">FreshMan</option> <option value="Sophomore">Sophomorer</option> <option value="Junior">Junior</option> <option value="Seniorr">Senior</option> </select> </label> how can I implement php code to select ONLY one of those items.... I need u r guidance or any reference THnaks in adv Link to comment https://forums.phpfreaks.com/topic/122603-hi-need-help-with-dropdown-menu/ Share on other sites More sharing options...
ngreenwood6 Posted September 3, 2008 Share Posted September 3, 2008 in your process1.php file you will have something like this: <?php //this selects what is selected in the dropdown box $students = $_POST['students']; ?> Hope this helps. Link to comment https://forums.phpfreaks.com/topic/122603-hi-need-help-with-dropdown-menu/#findComment-633041 Share on other sites More sharing options...
desiinusa123 Posted September 3, 2008 Author Share Posted September 3, 2008 but i have to enter the student into DB. for example in the dropdown the user chooses One freshman/sophomore/.....and that shoudl be inserted into DB. that is the deal...could u pls help me.\thanks Link to comment https://forums.phpfreaks.com/topic/122603-hi-need-help-with-dropdown-menu/#findComment-633105 Share on other sites More sharing options...
jej1216 Posted September 4, 2008 Share Posted September 4, 2008 If you are using MySQL, you would do something like this to insert data: <?php $db = mysql_connect("myhost", "blahlogin", "blahpw"); if (!$db) { die('Could not connect:'.mysql_error); } mysql_select_db("dbname",$db); $sql = "INSERT INTO tableA (fieldA, fieldB, fieldC) VALUES ('$_REQUEST[fieldA]', '$_REQUEST[fieldB]', '$_REQUEST[fieldC]')"; if (!mysql_query($sql,$db)) { die('Error: '.mysql_error()); } mysql_close($db); ?> Does that help? Link to comment https://forums.phpfreaks.com/topic/122603-hi-need-help-with-dropdown-menu/#findComment-633985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.