Page 1 of 1

extracting array from PDO fetchall() array

Posted: Sun Oct 02, 2011 4:29 am
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

Re: extracting array from PDO fetchall() array

Posted: Sun Oct 02, 2011 11:36 am
by egg82
$result = mysql_query("SELECT * FROM table WHERE user=user");

while($row = mysql_fetch_array($result){

}

why would you need to use PDO?