Passing to json_encode an array of all the MySQL table rows generated by row_array() |
[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!
[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.
[eluser]InsiteFX[/eluser]
You can read more about it here: CodeIgniter User Guide - Generating Query Results
|
Welcome Guest, Not a member yet? Register Sign In |