From e486d621c817d8ce47f212bb6b13ffc128f6df5f Mon Sep 17 00:00:00 2001 From: james Date: Mon, 6 Feb 2006 17:22:25 +0000 Subject: [PATCH] Avoid a 'foreach' on an empty array and ensure subcategories only show for the appropriate years. --- config/divisions.php | 8 ++++++-- config/subdivisions.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/divisions.php b/config/divisions.php index df20b08..0ae14e1 100644 --- a/config/divisions.php +++ b/config/divisions.php @@ -48,11 +48,15 @@ if($config['filterdivisionbycategory']=="yes"){ mysql_query("DELETE FROM projectcategoriesdivisions_link WHERE projectdivisions_id='".$_POST['saveid']."' AND year='".$config['FAIRYEAR']."'"); - foreach($_POST['divcat'] as $tempcat){ - mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,year) VALUES ( ". + if(is_array($_POST['divcat'])) + { + foreach($_POST['divcat'] as $tempcat) + { + mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,year) VALUES ( ". "'".$_POST['id']."', ". "'".$tempcat."', ". "'".$config['FAIRYEAR']."') "); + } } } //########### diff --git a/config/subdivisions.php b/config/subdivisions.php index e258088..1066b3d 100644 --- a/config/subdivisions.php +++ b/config/subdivisions.php @@ -149,6 +149,7 @@ projectdivisions WHERE projectsubdivisions.year='".$config['FAIRYEAR']."' + AND projectdivisions.year='".$config['FAIRYEAR']."' AND projectsubdivisions.projectdivisions_id=projectdivisions.id ORDER BY division,subdivision");