Re: assign value from fetch array

From: Date: Thu, 22 May 2014 14:46:13 +0000
Subject: Re: assign value from fetch array
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-323353@lists.php.net to get a copy of this message
Sorry, although i was not able to understand problem very much.. But if it is about transferring a php array to jquery... Then you can json encode the array in php and assign it dynamically to a jquery variable and then use parseJson in jquery to get the values in jquery I hope this might help.. Thanks Kumar On May 21, 2014 3:02 AM, "ICCSI" <inungh@gmail.com> wrote: > 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 (#323353) next »