maxat Posted February 13, 2009 Share Posted February 13, 2009 Hi, I have a problem inserting multiple drop down list options into MySql database. No problem with text fields, only with drop down. Can you please help me with it? Code is below. <?php for($i = 1; $i <= $items; $i++) { echo " <tr> <td width=3% align=center>$i<input type=hidden name=\"qid[]\" ></td> <td align=center colspan=2><textarea name=\"a1[]\" cols=40 rows=2 id=box></textarea></td> <td width=20% align=center><input type=text name=\"a2[]\" size=10 maxlength=10 id=box></td> <td width=11% align=center><SELECT id=box name=\"unit\"><OPTION value=each>each </OPTION> <OPTION value=ltr>ltr </OPTION> <OPTION value=box>box </OPTION> <OPTION value=can>can </OPTION> <OPTION value=kg>kg </OPTION> <OPTION value=dr>drum </OPTION> <OPTION value=pair>pair </OPTION> <OPTION value=ton>ton </OPTION> </SELECT></td> <td width=19% align=center><input type=text name=\"a4[]\" size=4 maxlength=10 id=box></td> </tr>"; }?> <tr> <td align="right" colspan="5"><input name="btnSave" type="submit" id="btnSave" value="Save"></td> </tr> </table> </form> <?php if($_POST){ $enqNum = $_POST['enqnum']; $compNum = $_POST['comp']; $unit = $_POST['unit']; $date = date(); foreach($_POST['qid'] as $idx => $val) { $qid = $val; $item = $_POST['qid'][$idx]; $a1 = $_POST['a1'][$idx]; $a2 = $_POST['a2'][$idx]; $a3 = $_POST['a3'][$idx]; $a4 = $_POST['a4'][$idx]; $sql = "insert into sales (id,company, enq_num, item_desc, item_pn, item_unit, item_qty, enq_date) values (null, '$compNum','$enqNum','$a1','$a2','$unit','$a4', '$date')"; $result = mysql_query($sql); } // EndForEach segment } // End if POST ?> Link to comment https://forums.phpfreaks.com/topic/145058-insert-multiple-drop-down-list-options/ Share on other sites More sharing options...
fenway Posted February 15, 2009 Share Posted February 15, 2009 Code like that doesn't help at all. What exactly is the problem? Have you echoed your sql statements. Link to comment https://forums.phpfreaks.com/topic/145058-insert-multiple-drop-down-list-options/#findComment-762698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.