Hello i am trying to submit an array of 3 textfileds from my form and then send to my database, table
my form
<input type="hidden" name="itemqt[]" value="<?php echo $item["quantity"]; ?>">
<input type="hidden" name="itemname[]" id="text-basic" value="<?php echo $item["name"]; ?>">
<input type="hidden" name="itemprice[]" id="text-basic" value="<?php echo $item["price"]; ?>">
basically when i attempt to combine two arrays it works
foreach (array_combine($_POST['id'], $_POST['itemprice'] ) as $name => $email)
{
echo "";
//$name . " - " . $email .
$ocode = $_POST['ocode'];
$sql = "INSERT INTO `orders` (pid, price,status,method,ocode, quantity) VALUES ('$name','$email','paid','Card','$ocode','$_POST[itemqt]')";
if (mysqli_query($con, $sql)) {
echo "";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
}
}
}
but when i try to attempt to combine a 3 array, with another field like dis, it fails. i get a syntax error
foreach (array_combine($_POST['id'], $_POST['itemprice'], $_POST['itemqt'] ) as $name => $email, $qt)
{
echo "";
//$name . " - " . $email .
$ocode = $_POST['ocode'];
$sql = "INSERT INTO `orders` (pid, price,status,method,ocode, quantity) VALUES ('$name','$email','paid','Card','$ocode','$_POST[itemqt]')";
if (mysqli_query($con, $sql)) {
echo "";
}
else {
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
}
}
}
please any idea, has someone successfully combined 3 arrays
$name => $email. It's going to give you a number as$nameand either quantity, name, or price as$email