Usage of mysql_fetch_array () function in php

Source: Internet
Author: User
Usage of mysql_fetch_array () function in php
This article describes the usage of the mysql_fetch_array () function in php. it returns the data query results in the form of arrays. For more information, see.

Php Data Query result function: mysql_fetch_array () function. Returns the data query result in an array.

Syntax: array mysql_fetch_array (int result, int [result_typ]);

Returned value: Array Function type: database function

This function is used to split the query result into array variables. If the result contains no data, false is returned. This function is the enhancement function of mysql_fetch_row (). In addition to putting the returned column and numeric index into the array, you can also put the text index into the array.

If multiple returned fields are the same text names, the last field is valid. Solution: Use a digital index or use an alias (alias) for these columns with the same name ).

Note: the processing speed of using this function is actually not slower than that of the mysql_fetch_row () function. it depends on the function to be used. The result_typ parameter is a constant value and has the following constants: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH.

Let's look at an example. Output all rows of the_id and a_name fields in the table of the database. Code:

     

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.