In-depth mysql_fetch_row () and mysql_fetch_array () _php Tutorial

Source: Internet
Author: User
These two functions return an array, the difference is that the first function returns an array that contains only the values, we can only $row[0],
$row [1], which reads the data as an array subscript, and the array returned by Mysql_fetch_array () contains both the first and key values
In the right form, we can read the data in this way (if the database field is USERNAME,PASSWD):
$row [' username '], $row [' passwd ']
Furthermore, if you use ($row as $kay + $value), you also get the field name of the database directly.
More important is that mysqli is a new library of functions provided by PHP5, (i) for improvement, and for faster execution.
For example
Copy CodeThe code is as follows:
Code highlighting produced by Actipro Codehighlighter (freeware) http://www.codehighlighter.com/--> Connect to the local MySQL database and select test as the action library
$mysqli = Mysqli_connect ("localhost", "root", "" "," Test ", 3306);
Using the Mysql_query function to read data from the user table
$result = Mysqli_query ($mysqli, "select * from UserInfo");
while ($row = Mysqli_fetch_array ($result))//Read data contents by loop
{
?>





}
To close a connection to a database
Mysqli_free_result ($result);
Mysqli_close ($MYSQLI); * *
?>

http://www.bkjia.com/PHPjc/327342.html www.bkjia.com true http://www.bkjia.com/PHPjc/327342.html techarticle Both functions return an array, the difference is that the first function returns an array that contains only the values, we can only $row[0], $row [1], so that the array subscript to read the data, and my ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.