SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql_fetch_array

    When using:

    while ($article_info = mysql_fetch_array($result)) // List contents of row
    {

    do whatver

    }

    If I use $article_info after the loop, I get nothing because it has already gone through all the rows in $result. How do I get it to start from the begining again?

  2. #2
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Are you using $article_info like this:
    PHP Code:
    while ($article_info mysql_fetch_array($result)) // List contents of row 
    {
        echo 
    $article_info["column name"];

    ??

    I would just do another $article_info = mysql_fetch_array($result);
    after the while loop.

    Hope that helps.
    Last edited by Hartmann; Jun 2, 2001 at 13:19.

  3. #3
    ********* Addict
    Join Date
    Apr 2000
    Location
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apparently mysql_data_seek() should do the job. I've never used it but here's a guess on how to reuse $article_info:
    PHP Code:
    while ($article_info mysql_fetch_array($result)) // List contents of row 
    {
        echo 
    $article_info["column name"];
    }
    mysql_data_seek ($result,0);
    // do it again!
    while ($article_info mysql_fetch_array($result)) // List contents of row 
    {
        echo 
    $article_info["column name"];



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •