Jump to content

Insert Multiple Drop down list options


maxat

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.