Got a lot of if statements in other if statements. Now, problem is I don't want things updating in the database if other things haven't been selected to be changed.
This is the code for the SQL:
if ($Type == "networkuni") {
if (empty($city) || empty($country)) {
$query = "UPDATE NETWORKUNI SET picture = '$picture', title = '$title', shorttext = '$shorttext', `text` = '$text', level = '$level', `url` = '$url' WHERE networkuniid = '$id'";
} else {
$query = "UPDATE NETWORKUNI SET picture = '$picture', title = '$title', shorttext = '$shorttext', `text` = '$text', level = '$level', `url` = '$url', filecat = '$country', filesubcat = '$city' WHERE networkuniid = '$id'";
}
if (empty($picture)) {
$query = "UPDATE NETWORKUNI SET title = '$title', shorttext = '$shorttext', `text` = '$text', level = '$level', `url` = '$url' WHERE networkuniid = '$id'";
} else {
$query = "UPDATE NETWORKUNI SET picture = '$picture', title = '$title', shorttext = '$shorttext', `text` = '$text', level = '$level', `url` = '$url', filecat = '$country', filesubcat = '$city' WHERE networkuniid = '$id'";
}
} else if ($Type == "venue") {
$query = "UPDATE MEETINGS_VENUES SET title = '$title', directions = '$directions', map = '$map', area = '$area', address = '$address' WHERE venueid = '$id'";
}
The problem seems to be the if statements in the networkuni $Type...
I want to do a check. Because if I use the form, and I leave one of those options blank, for example $picture, but I select something in both $city and $country, then I want it to update the $city and $country fields, but not the picture field and vice versa, if I select a $picture but nothing else, then only update the $picture field.
If I select both then update both fields. If I select nothing, don't update anything.
I'm not sure which is the best way about this, any ideas guys?
Cheers,
Chris