I enter this in the textboxes (which are dynamically added text boxes). Say i generate 2 textboxes and i enter the following data.
Data
e1 (<input type="text" name="myInputs[]"> Entry1)
a1 (<input type="text" name="myInputs2[]"> Amount1)
e2 (<input type="text" name="myInputs[]">Entry2)
a2 (<input type="text" name="myInputs2[]">Amount2)
then i post to the next page which contains the following code.
Code: Select all
$myInputs = $_POST["myInputs"];
$myInputs2 = $_POST["myInputs2"];
$myInputC = 1;
$myInputC2 = 1;
foreach ($myInputs as $eachInput) {
echo "Entry " . $myInputC . " - " . $eachInput . "<br>";
foreach ($myInputs2 as $eachInput) {
echo "Amount " . $myInputC2 . " - " . $eachInput . "<br>";
}
$myInputC++;
$myInputC2++;
}
Entry 1 - e1
Amount 1 - a1
Amount 2 - a2
Entry 3 - e2
Amount 3 - a1
Amount 4 - a2
when im trying to get to show something like this
Entry 1 - e1 Amount 1 - a1
Entry 2 - e2 Amount 1 - a2
I can get it to work if i put the foreach loop separately, but as i'm going to place this into a database, i want it to be able to INSERT into the table in one go.
Code: Select all
mysql_query("INSERT INTO `$db_name`.`$tbl_name` (`Entry1`, `Amount1`) VALUES ('$eachInput', '$eachInput2')");