I have look all over youtube and forms and I still can't find an answer that works. I want use a php loop to update database values. I need something like the two last loops below. Thanks in advance.
<?php
if (isset($_POST['update'])) {
for ($i = 1; $i <= 6; $i++) {
$heading[$i] = $_POST['heading' . $i];
}
for ($i = 1; $i <= 9; $i++) {
$des[$i] = $_POST['des' . $i];
}
for ($i = 1; $i <= 6; $i++) {
$update = mysqli_query($connect, "UPDATE info1 SET heading[$i]='$heading[$i]' WHERE id= $i");
}
for ($i = 1; $i <= 9; $i++) {
$update = mysqli_query($connect, "UPDATE info1 SET des[$i]='$des[$i]' WHERE id= $i");
}
header('Location: admin.php?success');
exit();
}
?>
if (!$update) { die(mysqli_error($connect)); }so you can get told about your sql syntax errors.des[0], -des[100], these queries are going to failname=heading[]andname=des[]in your form, so that the$_POSTvariables will be arrays. Then you don't need the first two loops.