I know similar questions have been asked a lot, and I have searched through and am unable to find an answer that fixes the problem I am having.
I have a form with multiple textareas that updates a mysql entry, and I would like PHP to make sure there is something in the textarea before updating the entry. This works when I only have one entry being updated, but when I do more than one at a time only the last one is updated. I tried using else if, and in that case only the first one is updated. How can I make it update all entries where text has been entered?
In my code the form input name matches the column name.
$value = $_POST['titleLeft'];
$value2 = $_POST['textLeft'];
$value3 = $_POST['imgName'];
$value4 = $_POST['titleRight'];
$value5 = $_POST['textRight'];
if (strlen($value) > 0){
$sql = "UPDATE classesSpecial SET titleLeft = '$value' WHERE id = '1'";
}
if (strlen($value2) > 0){
$sql = "UPDATE classesSpecial SET textLeft = '$value2' WHERE id = '1'";
}
if (strlen($value3) > 0){
$sql = "UPDATE classesSpecial SET imgName = '$value3' WHERE id = '1'";
}
if (strlen($value4) > 0){
$sql = "UPDATE classesSpecial SET titleRight = '$value4' WHERE id = '1'";
}
if (strlen($value5) > 0){
$sql = "UPDATE classesSpecial SET textRight = '$value5' WHERE id = '1'";
}