What I am doing is editing the data of MySQL data using PHP using form.
I have two text field as name and mobile number. When I click on edit, I get same data in text field and below I have Save button. When I do changes I get response as done, but when I click edit and don't do any changes in text field and click Save I get response as fail.
Below is code for SAVE button.
$sql = mysql_query("
UPDATE userInfo SET fullName='$fullName',
mobileNumber='$mobileNumber'
WHERE id=$tagNumberId"
);
if (mysql_affected_rows()==1) {
echo "done";
} else {
echo "fail";
}
I am worried about mysql_affected_rows()
.
Above makes me think that if data is same in UPDATE statement, mysql_affected_rows()
will return 0 and if data is not same in UPDATE statement, mysql_affected_rows()
will return 1.
Is this right? If it is right, how to deal with whether the update is done or not?