extracting array from PDO fetchall() array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rusty009
Forum Newbie
Posts: 1
Joined: Sun Oct 02, 2011 4:22 am

extracting array from PDO fetchall() array

Post by rusty009 »

Hi,

I am very new to PHP programming and am using PDO to extract data from my database, I currently have a function which returns all rows and columns from a table in my database with a similar code to that shown below,

Code: Select all

$result = $stmt->fetchAll();
I then return the result so when I need the data I use,

Code: Select all

$member_info=MyFunction();
This bit works fine and I know it works as I have used print_r() to output the entire array, the only problem I have is outputting the data in my desired format. I would like to extract each piece of data from the array individually and have tried using

Code: Select all

 $member_info[x][y]
but with no luck, can anyone think How I could do this ? Thanks,

Paul
User avatar
egg82
Forum Contributor
Posts: 156
Joined: Sat Oct 01, 2011 9:29 pm
Location: Colorado, USA

Re: extracting array from PDO fetchall() array

Post by egg82 »

$result = mysql_query("SELECT * FROM table WHERE user=user");

while($row = mysql_fetch_array($result){

}

why would you need to use PDO?
Post Reply