![]() |
Passing to json_encode an array of all the MySQL table rows generated by row_array() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Passing to json_encode an array of all the MySQL table rows generated by row_array() (/showthread.php?tid=60317) |
Passing to json_encode an array of all the MySQL table rows generated by row_array() - El Forum - 02-28-2014 [eluser]Unknown[/eluser] Hello guys, my first post here with the hope you can help me out for a problem I've been having. What I need to do is to pass to json_encode an array, that is the result of the row_array() function. In my model, in fact, i have a very simple function Code: public function tuttiProdotti() That gives to my controller an array with more than one row. In the function of my controller I have Code: if($item = $this->inventories_model->tuttiProdotti()) { As you may expect this gives to my json_encode datas for only one row (I think the last selected row?) while I want to pass it an array, made itself of ARRAYS (the $product variable). Any help to find out how to achieve this, and how to retreive the data in a later phase, would be greatly appreciated. I hope you can help me go out of this mess! Passing to json_encode an array of all the MySQL table rows generated by row_array() - El Forum - 02-28-2014 [eluser]InsiteFX[/eluser] Code: $product = array(); When dealing with data like that you need to use a foreach loop. So it would be something like that. Not tested. Passing to json_encode an array of all the MySQL table rows generated by row_array() - El Forum - 02-28-2014 [eluser]InsiteFX[/eluser] You can read more about it here: CodeIgniter User Guide - Generating Query Results Passing to json_encode an array of all the MySQL table rows generated by row_array() - El Forum - 02-28-2014 [eluser]InsiteFX[/eluser] Duplicate post please delete |