This is a piece of code that works:
$count_cl+=1;
for ($i=1; $i<$count_cl; $i++) {
if (${"delete_".$i} == "Delete") {
$sql = "UPDATE country SET zone_id='0' WHERE country_id='${"country_id_".$i}'";
$result = @mysql_query($sql,$connection) or die("Couldn't delete from zone.");
}
}
This is the same piece of code put into a function:
FUNCTION CALL:
shippingupdatezone($zone_id,$count_cl, ${"delete_".$i}, ${"country_id_".$i});
FUNCTION:
function shippingupdatezone($zone_id,$count_cl, $delete, $countryID) {
if (!$count_cl) {
header("location: .....BLAH");
exit;
}
else {
$count_cl+=1;
for ($i=1; $i<$count_cl; $i++) {
if ($delete == "Delete") {
$sql = "UPDATE country SET zone_id='0' WHERE country_id='$countryID'";
$result = @mysql_query($sql,$connection) or die("Couldn't delete from zone.");
}
}
header("location: BLAH....&zone_id=$zone_id");
exit;
}
}
The second piece of code does not work and I do not understand why. Does anyone have any idea? I am new to functions and was informed that this was the way to handle my variable variables.
The part I do not understand (a part from the fact that this clearly does not work) is that at the point of the function call the $i var is not set.....