Skillfully used: mysql_num_rows--get the number of rows in the result set;--for Select Lookup$query =mysql_query (SELECT * FROM table_name); if ($query && mysql_num_rows ($query))//Perform data output only when there is data in the database{while ($row = Mysql_fetch_row ($query)) {echo $row. <br> "; }}else{echo "No data!" ";}//If you change to if ($query) the query succeeds even if no data is still outputSkillfully used: mysql_affected_rows ([Resource $link _identifier])--A parameter "database resource" obtainedlast timeAssociated with the Link_identifierinsert,update or DELETEThe number of record rows affected by the query.This function is removed after PHP5.5.0, it is recommended to use: Mysqli_affected_rows () or Pdostatement::rowcount ()$query = mysql_query ("UPDATE table_name set name= ' LMS ' where ID <); if ($query && mysql_affected_rows ($con))//The output succeeds only if the updated data succeeds successfully-when the updated data is consistent with the original data, the affected data is 0 and is not updated{echo ' modified successfully! ‘;} else{Echo ' modification failed ';}
Avoid waste of database resources