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!!!
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.