Mysql_fetch_array () issue

Source: Internet
Author: User
while ($row =mysql_fetch_array ($result))
{
echo $row [0];
}
Why this will be able to put the data of the query one output, but put into the for loop inside no, shape such as:
for ($i =0; $i <366; $i + +)
{
echo $row [0];
}
This will not be the correct output of the data!

If I want to put the data queried from the database into a for loop what to do, like Odbc_fetch_into ($result, $row) function has no, put the data results into the array, through the array of the following table to manipulate the data set. Please teach the great God.


Reply to discussion (solution)

Use for loop to write

for ($i =0; $row =mysql_fetch_array ($result); $i + +) {  echo $row [0];}


while ($row =mysql_fetch_array ($result))
{
Array_push ($array, $row [0]);
}
Var_dump ($array);

Use for loop to write

for ($i =0; $row =mysql_fetch_array ($result); $i + +) {  echo $row [0];}

This is a dead loop.

Why is the cycle of death?

You seem to have more than one database field, but you do echo $row [0];

Use for loop to write

for ($i =0; $row =mysql_fetch_array ($result); $i + +) {  echo $row [0];}


while ($row =mysql_fetch_array ($result))
{
Array_push ($array, $row [0]);
}
Var_dump ($array);


Study the

Landlord does not understand the difference between for and while Ah

  • 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.