PHP connection MySQL I have already written the article, this article is mainly about the query from the MySQL results after the output of the problem.
One: Mysqli_fetch_row ();
Query Result: Array ([0]=> Xiao Wang)
Inquire:
while ($row = Mysqli_fetch_assoc ($result)) {
$memberlist = $row [0];
}//end while ()
II: Mysqli_fetch_assos ();
Query Result: Array ([name]=> Xiao Wang)
Inquire:
while ($row = Mysqli_fetch_assoc ($result)) {
$memberlist = $row [' memberlist '];
}//end while ()
Third, Mysqli_fetch_array ();
Query Result: Array ([0]=> Xiao Wang [name]=> Xiao Wang)
Inquire:
while ($row = Mysqli_fetch_assoc ($result)) {
$memberlist = $row [' memberlist '];
$memberlist = $row [0];
}//end while ()
Iv. Fetch_array ();
Query Result: Array ([0]=> Xiao Wang [name]=> Xiao Wang)
Enquiry: ' sql= ' select?fromuser '; result = Conn?>query (SQL);
if (result)
{
if (result->num_rows>0)
{
while (rows= Result->fetch_array ()) {
Print_r (rows); echo "Rows[' id′]:". rows[' id '];
echo "
rows[' name ']: ". rows[' Name′];echo "rows[' pwd′]:". rows[' pwd '];
}//end while ()
}else{
echo "
The query result is empty! ”;
}//end if ()
}else{
echo "
Query failed! ”;
}//end if () '
From the above can be seen different function output format is not the same, Mysqli_fetch_row () is returned by the number index, Mysqli_fetch_assos () is indexed by the keyword, and Mysqli_fetch_array () and Fetch_array () the use of numbers also uses keywords to index.