Re: assign value from fetch array

From: Date: Tue, 20 May 2014 21:31:09 +0000
Subject: Re: assign value from fetch array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-323352@lists.php.net to get a copy of this message
Thanks for the message, Yes, I use PDO to create connection and and use fetchAll to get data. The print result and iterate work, but I need pass the value to calling function from jQuery. I tried to use fetch which still returns an array. I want to learn how I can access array and assign an array value to my variable and send back to calling function. Thanks again for helping, Regards, Iccsi, On Mon, May 19, 2014 at 11:03 PM, Ricardo R Bonfim <ricobonfim@gmail.com>wrote: > If I got it correctly, you're using PDO and using Statement fetchAll > method, which would return an array of arrays. > > Your variable $row would fit best as $rows if you know what I mean... > try to iterate over the return of fetchAll and give it a print to see > how it looks like. > > 2014-05-19 20:57 GMT-03:00 ICCSI <inungh@gmail.com>: > > I have following code to fetch data from database. > > I am able to print the array, but I got HTTP 500 error when I assign the > > array the value to echo the result. > > > > I think I am missing something between array and variable. > > > > Your help and information is great appreciated, > > > > Iccsi, > > > > > > $row = $sth->fetchAll(PDO::FETCH_ASSOC); > > print_r($row); > > print("\n"); > > $name = "{$row['MyID']}"; > > echo $name; > > > > -- > Att, > ____________________________________________________ > Ricardo R Bonfim >

« previous php.general (#323352) next »