#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    1
    Rep Power
    0
    How do I get data returned from mysql into a multi-dimensional array?
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    $query="select * from table";
    $result=mysql_query($query);

    while ($data[]=mysql_fetch_row($result)){}

    This will create $data as a two dimensional array where the first index is the row (starting at 0) and the second index is the field element (starting at 0). Alternately, you can make the second element the name of the table field with:

    while ($data[]=mysql_fetch_array($result)){}

Similar Threads

  1. C program to read from a data file into an array
    By rathornton in forum C Programming
    Replies: 4
    Last Post: March 16th, 2004, 11:23 AM
  2. Replies: 3
    Last Post: February 11th, 2004, 08:30 AM
  3. mysql data lost
    By imola in forum MySQL Help
    Replies: 1
    Last Post: February 10th, 2004, 07:39 AM
  4. Inserting checkbox values from an array into MySQL
    By outlyr242 in forum PHP Development
    Replies: 1
    Last Post: February 9th, 2004, 04:28 PM
  5. Replies: 1
    Last Post: February 5th, 2004, 06:17 AM

IMN logo majestic logo threadwatch logo seochat tools logo