While ($ rs = mysql_fetch_array ($ result)

Source: Internet
Author: User
While ($ rs = mysql_fetch_array ($ result) 1. you do not need to move the record pointer to this loop. Can we read records cyclically? 2. does the expression $ rs = mysql_fetch_array ($ result) return TRUE, or if $ RS has a value, it is equivalent to TRUE while ($ rs = mysql_fetch_array ($ result ))
1. you do not need to move the record pointer to this loop. Can we read records cyclically?
2. is the expression $ rs = mysql_fetch_array ($ result) TRUE returned, or is it equivalent to TRUE when $ RS has a value.

Thank you ..

------ Solution --------------------
If $ rs is always true, isn't it an endless loop ?, Therefore, when the array is obtained, the value of $ rs is true. when the array is read, $ rs is null, which is false. I'm a newbie, so I understand
------ Solution --------------------
Mysql_fetch_array () is an extension of mysql_fetch_row.

Mysql_fetch_row () retrieves a row of data from the result set associated with the specified result ID and returns it as an array. Each result column is stored in an array unit, and the offset starts from 0. Call mysql_fetch_row () in sequence to return the next row in the result set. If no more rows exist, FALSE is returned.

------ Solution --------------------
Discussion
If the expression has a value, can it be considered TRUE?

------ Solution --------------------
Of course, if there is a value, the returned array will be equivalent to true.
------ Solution --------------------
Characters can be converted from BOOL,
Use two !! Can be converted to BOOL (TRUE)

PHP code
Echo !! $ Rs = mysql_fetch_array ($ result); // returns 1, indicating that there is a value. If no value is returned, no value is returned.

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.