mysql - find number of updates done in PHP -
what doing editing info of mysql info using php using form.
i have 2 text field name , mobile number. when click on edit, same info in text field , below have save button. when changes response done, when click edit , don't changes in text field , click save response fail.
below code save button.
$sql = mysql_query(" update userinfo set fullname='$fullname', mobilenumber='$mobilenumber' id=$tagnumberid" ); if (mysql_affected_rows()==1) { echo "done"; } else { echo "fail"; }
i worried mysql_affected_rows()
.
above makes me think if info same in update statement, mysql_affected_rows()
homecoming 0 , if info not same in update statement, mysql_affected_rows()
homecoming 1.
is right? if right, how deal whether update done or not?
use mysqli_info, after executing query
$string = mysqli_info ( $link );
returns string having relevant information, update
rows matched: 40 changed: 40 warnings: 0
in case, 1 row updated no change, should get
rows matched: 1 changed: 0 warnings: 0
you can retrieve value from
preg_match("/rows matched: (\d+)/", $string, $matches); $number_of_rows = intval($matches[1]);
php mysql rows-affected
No comments:
Post a Comment