Reputation: 13641
I have a list of update querys, but was wondering if there's a quicker or better way of doing this, maybe with some kind of loop.
mysql_query("UPDATE turfs SET 1 = '0' WHERE 1 = '$corpse_gang'");
mysql_query("UPDATE turfs SET 2 = '0' WHERE 2 = '$corpse_gang'");
mysql_query("UPDATE turfs SET 3 = '0' WHERE 3 = '$corpse_gang'");
mysql_query("UPDATE turfs SET 4 = '0' WHERE 4 = '$corpse_gang'");
mysql_query("UPDATE turfs SET 5 = '0' WHERE 5 = '$corpse_gang'");
mysql_query("UPDATE turfs SET color1 = '0' WHERE color1 = '$g_color'");
mysql_query("UPDATE turfs SET color2 = '0' WHERE color2 = '$g_color'");
mysql_query("UPDATE turfs SET color3 = '0' WHERE color3 = '$g_color'");
mysql_query("UPDATE turfs SET color4 = '0' WHERE color4 = '$g_color'");
mysql_query("UPDATE turfs SET color5 = '0' WHERE color5 = '$g_color'");
Upvotes: 0
Views: 82
Reputation: 66687
Yes, I think it would be something like this:
for ($i = 1; $i <= 5; $i++) {
mysql_query("UPDATE turfs SET " . $i . " = '0' WHERE " . $i . "= '$corpse_gang'");
mysql_query("UPDATE turfs SET color" . $i . " = '0' WHERE color" .$i . " = '$g_color'");
}
Upvotes: 1