Question : PHP if statament  and SQL script

Dear experts,
I have question concerning if statement

$result = mysql_query("SELECT * FROM Mytable where Email=$email and Confirmation=$ConfirmationCode")
or die(mysql_error());  

I want to write here an if statement that if result  of this sql script is 0
I want to modify my Approve column in Mytable where Email=$email and Confirmation=$ConfirmationCode


Answer : PHP if statament  and SQL script

If you are sure that there is a record with primary key equal to your $email you can just update the record with the following. Remember both ' around $email.

"UPDATE Mytable SET Approve=1 WHERE Email='$email'"

If you don't have a record with key equal to your $email you have to create the record

"INSERT INTO Mytable (Email, Approve) VALUES ('$email', 1)"
Random Solutions  
 
programming4us programming4us