From 722d4d1e148f086dfc321c51bf03363a33c0562d Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 16 Jan 2003 11:57:34 +0000 Subject: [PATCH] Cleaned up the logic a bit --- course/categories.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/course/categories.php b/course/categories.php index 63c6763582..a07f95f3f0 100644 --- a/course/categories.php +++ b/course/categories.php @@ -37,16 +37,18 @@ // Peel out all the data from variable names. foreach ($form as $key => $val) { - if ($key == "new" and $val != "") { - $cat->name = $val; - if (!insert_record("course_categories", $cat)) { - error("Could not insert the new category '$val'"); - } else { - notify(get_string("categoryadded", "", $val)); + if ($key == "new") { + if (!empty($val)) { + $cat->name = $val; + if (!insert_record("course_categories", $cat)) { + error("Could not insert the new category '$val'"); + } else { + notify(get_string("categoryadded", "", $val)); + } } } else { - $cat->id = substr($key,1); + $cat->id = substr($key,1); $cat->name = $val; if (!update_record("course_categories", $cat)) { error("Could not update the category '$val'"); -- 2.39.5