SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    create array with mysql_fetch_array()

    How do I create an array of all the results from my mysql query using mysql_fetch_array()? This code is close, but produces severe data duplication. Am I on the right track?
    Code:
    while ($result2[] = mysql_fetch_array($result)) {
    }

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    453
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Got it.
    Code:
    while ($result2 = mysql_fetch_array($result)) {
     $result3[] = $result2;
    //echo '<br/>';
    }

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    88
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Actually - since you really should be moving away from the MySQL_*** functions/interface, you could be using PDO and the FetchAll function to do this.


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
  •