I am a bit unfamilar with IF / ELSE statements in MySQL ( apparently ) Basically what i am trying to do is if the member's value is 1, set it to 0... else set it back to 1. i know my code is not the most efficient in the world ( or correct for that matter ) but can anybody help?
this is the code for a hyperlink when i click on their username.
if($cmd == "member")
{
mysql_query("IF `member` = '0' THEN ".
"UPDATE `TABLE1` SET `member` = '1' WHERE `member` = '0' ".
"ELSE ".
"UPDATE `TABLE1` SET `member` = '0' WHERE `member` = '1' ".
"")or die(mysql_error());
echo "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=?show=mypage'>";
} // end if.
the error i receive :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF `member` = '0' THEN UPDATE `TABLE1` SET `member' at line 1