Re: [mccode v2] Events Page Updated.
@killah
Fine, I'll try and explain.
IN() accepts a comma separated list of values, so all of these are equal:
WHERE x IN (1,2,3)
WHERE x = 1 OR x = 2 OR x = 3
WHERE x > 0 AND x < 4
What you're doing, is only putting on value in it.
This:
WHERE x IN (1,2,3)
is equal, and clearly much better, than this:
q1: WHERE x IN(1)
q2: WHERE x IN(2)
q3: WHERE x IN(3)
And using IN() with only one value is pointless since you can just use equals. You're saying "where it is in this group of numbers, and this group only contains one number"
Now what you're doing with the checkboxes is fine, but you're looping over each one, so if they delete ten events, you'll run ten queries, when they can all be condensed into one.
If you want a quicker way, here:
From this:
for($i = 0; $i < count($_POST['checkbox']); $i++)
{
mysql_query("DELETE FROM `events` WHERE `evID` IN(".$_POST['checkbox'][$i].") AND `evUSER` = ".$ir['userid']);
$result = 1;
}
To this:
$boxes = implode(',',$_POST['checkboxes']);
mysql_query('DELETE FROM `events` WHERE `evID` IN ("'.$boxes.'") AND `evUSER` = "'.$ir['userid'].'"');
Shouuuuuuuld work