Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use mysql_fetch_row () to return query results as an array

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use mysql_fetch_row () to return query results in the form of an array", the content is simple and clear, hoping to help you solve your doubts, the following let the editor lead you to study and learn "how to use mysql_fetch_row () to return query results in the form of an array" this article.

Like mysql_result (), mysql_fetch_row () can also be used to get the query result set, except that the return value of the function is not a string, but an array. The function is defined as follows.

The copy code is as follows:

Array mysql_fetch_row (int result)

The parameters are described below.

Result: identified by the result returned by the function mysql_query () or mysql_db_query (), it is used to specify the SQL statement type of the data to be fetched.

The function returns the following value.

Success: an array that contains the current row data information in the query result set, the array subscript range 0 ~ the number of record attributes − 1, and the value of the I element in the array is the value on the I attribute of the record.

Failed: false.

The following mysql_fetch_row () uses the same sample functionality as the example in 5.5.1.

The copy code is as follows:

one

two

Mysql_fetch_row () gets the data information for the current row and automatically slides to the next row after it is referenced. In this example, the reference to it in line 12 is:

The copy code is as follows:

While ($row=mysql_fetch_row ($result))

In this loop, each time mysql_fetch_row () takes the current row of data, assigns it to the array $row, and then automatically slides to the next row; after fetching the last row, the function returns false, and the loop ends. In this way, all the data in the result set can be taken out and displayed row by row.

Be careful

Mysql_fetch_row () returns the subscript of the result array corresponding to the values on different attributes, and it can only be obtained by subscript, not the attribute name, which is easy to cause confusion in practical application, so you must use it carefully. At the same time, care should be taken not to use out-of-bounds subscripts.

The above is all the contents of the article "how to use mysql_fetch_row () to return query results in an array". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report