Jump to content

help with inserting an array into database


DataSpy

Recommended Posts

I'm using a for loop to create a specific number of containers, lets say 3, and each container has a different number.  I want to create an entry in the database for each contain but I've never done this before and has no idea about how to go about doing it.  Here some code in case it's hard to understand

[code]
<tr>
<td>
&nbsp;Company
    </td>
<td>
&nbsp;<input type="text" name="company" size="18">
</td>
</tr>
<tr>
<td>
&nbsp;Booking Number
    </td>
<td>
&nbsp;<input type="text" name="booking_num" size="18">
</td>
</tr>
<?php
$number_of_containers=$HTTP_POST_VARS['number_of_containers'];
for($i=0; $i < $number_of_containers; $i++){
echo "
<tr>
<td>
&nbsp;Container " .($i+1). "
</td>
<td>
&nbsp;<input type='text' name='containers[$i]' value='Container #' size='18'>
</td>
</tr>";}
?>
<tr>
[/code]

Then for each container # i want an entry in the database with the same company and booking#, but the container #'s will all be different.  I know how to enter stuff into a database, I just need help with this array. 

Any help greatly appretiated, thanx in advance!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.