Hey everyone,
I'm sure this has been answered, but I've scoured the boards and all I could find was multiple inserts via forms.
What I'm trying to do is insert multiple rows into the items table of my database via a query. Below is the code I have thus far (no inserts etc.).
As you can see, it just loops through, grabbing all relevant entries and displays them (there are usually more fields, I've cut the code down to just 1 for troubleshooting).
<?php
$query = "SELECT * FROM orderItems o, items i
WHERE o.itemID = i.itemID
AND o.orderID = '$_POST[orderID]'";
$result = mysql_query($query) or die("Select Failed!");
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$description=mysql_result($result,$i,'description');
?>
<tr>
<td align="left" class="table_cell_alt"><? echo "$description"; ?></td>
</tr>
<?
++$i;
}
?>
What I need to do is have each row returned placed into an array and inserted. So if there are 4 descriptions, I hope to insert 4 new descriptions into the items table (with new itemIDs via autoincrement).
I've looked into using something similar to:
for($i = 0; $i < count($array1); $i++) {
echo $array1[$i];
echo $array2[$i];
echo $array3[$i];
}
but I'm just now sure how to incorporate that into my current code...
Thanks, and I hope that makes sense.
B