Re: assign value from fetch array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>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@xxxxxxxxx>:
> > 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
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux