A few days while writing the recent open source project, I encountered a problem is as follows

Post the source code

<? php include 'codeBack.config.php'; include "connectMysql.php"; include "empty.php"; header("connection","keep-alive"); $date = $_POST["date"]; $morning = $_POST["morning"]; $afternoon = $_POST["afternoon"]; $evening = $_POST["evening"]; $other = $_POST["other"]; $userid = $_POST["user_id"]; $token = $_POST["token"]; $ac_user_sql = "SELECT * from ac_user WHERE user_id='$userid' AND token='$token'"; $ac_user_result = $mysqli->query($ac_user_sql); $ac_user_row = mysqli_fetch_object($ac_user_result); If ($ac_user_row->token == $token && $AC_user_row ->user_id == $userID){$ac_user_info_sql = "INSERT INTO ac_user_info (date,morning,afternoon,evening,other,user_id) VALUES('$date','$morning','$afternoon','$evening','$other','$userid')"; $ac_user_info_result = $mysqli->query($ac_user_info_sql); If ($ac_user_info_result){$data = [" code"=>$CodeBack[" addinfo_code "], "User_id" = > $ac_user_row - > user_id, "id =" "> $mysqli - > insert_id," message "= >" add success, "]; echo json_encode($data); }else {$data = [" code"=>$CodeBack["ADDINFO_FAILED_CODE"], "message"=>" echo json_encode($data); }}Copy the code

Hence this article, so let’s write about their differences

1, mysqli_fetch_row ()

Mysqli_fetch_row fetches one piece of data from the result set at a time from the execution and returns it as an array of indexes corresponding to the order in which the fields were queried

$row[0] specifies the number field, and $row[3] specifies the job field

Operations on arrays can only be performed with numeric indexes

When the last result is reached, the next one returns null (false)

Mysqli_fetch_assoc () mysqli_fetch_assoc() mysqli_fetch_assoc() mysqli_fetch_assoc(

Mysqli_fetch_array () mysqli_fetch_array(); MYSQL_NUM(); MYSQL_ASSOC(); MYSQL_ASSOC();

Mysqli_fetch_object () mysqli_fetch_object returns an array object that manipulates data as an object property

The main difference between the four methods is that the form of the returned array is different, which can be selected as needed in practical programming. The article reference since: blog.csdn.net/thevictory/…