PHP reads multiple data output from MySQL and encounters problems

Source: Internet
Author: User
The statement is about this.
$sql = "SELECT * from team where number between and 60";
Res=mysql_query ($sql);
while ($row =mysql_fetch_array ($res))
{
echo $row ["name"];
}


I was wondering, executing this program using CMD, and then I found that the while statement did not execute
Ask the great God for advice.
And why does the direct echo $row display the word array?
PHP Small white really ask for advice.
Hope great God Enlighten


Reply to discussion (solution)

$res = mysql_query ($sql, database connection Resource);
Although the second value is not required, your while cannot be executed, obviously while is false. The database data could not be obtained.

$row is an array, echo does not output an array, output what.

echo $row the words "array" is displayed because $row is an array.

To look at this, you should be able to list the records of the query.

$sql = "SELECT * from Team where number between", $res =mysql_query ($sql), $result = Array (), while ($row =mysql_fetch_ Array ($res)) {$result [] = $row;} Print_r ($result);
  • 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.