Jump to content

Retrieving Entire Resultset from MySQL


rwilkerson

Recommended Posts

I have a situation where I need to retrieve a set of records from a MySQL DB and, rather than display those results, reformat the resultset to JSON and return it to a calling page.  Ideally, I'd like to simply fetch an array of all results (an array of associative arrays), wrap it in json_encode() and go on my way.  Not only can I not find anything that tells me how to do it, I can't even seem to find anything that definitively tells me whether it's *possible*.

 

Initially, I tried this:

 

json_encode ( mysql_fetch_assoc ( $myresult ) )

 

But that only encodes the first record.

 

Can anyone lend me their PHP experience?  I haven't yet learned its ins and outs.

 

Thanks.

 

Rob

Link to comment
https://forums.phpfreaks.com/topic/49455-retrieving-entire-resultset-from-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.