SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Create an array from mySql data

    Is it somehow possible to store mySql data in an array without having to use a `while` loop in php?

    I only have 1 column here.

    PHP Code:
     $members $conn->prepare(Select id from members where state 'CA');
        
    $members->execute();
        
    //Result ->1, 2, 3, 4, 5, 6, 7, 8, 9
        //$myarray = array of the above results.
        
    $myarray = array(123456789)//Has to be this kind of array. 
    I'm trying to avoid another while loop here, since this thing goes inside some more code.

  2. #2
    SitePoint Guru bronze trophy
    Join Date
    Dec 2003
    Location
    Poland
    Posts
    925
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    I think you might be interested in fetchAll with PDO::FETCH_COLUMN

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sometime ago I used fetch_column and things went horribly wrong. But I guess I have no option here but to use this.


Tags for this Thread

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
  •