Send qry results to array- retrieve w/specific format for use in JS file |
[eluser]justmelat[/eluser]
Hi We want to try a few things using the required fields we have in our CI 1.7.2 app. We've got the query pulling the data we want, but need to dump the data into an array, in a strict format, so we easily work with it in an external JS file. Here is the qry we're using: $myquery2 = $this->db->query("select account_id, display_name, id from field where account_id = $holdAcctID and required_flag = 1"); Code: <?php $toHoldArr = array(); Quote:["conn_id"]=>We want it to go into the array var like this: array[0] ["account_id"] => "3" ["display_name"] => "Project Name/Title" ["id"]=>"18" array[1] ["account_id"] => "3" ["display_name"] => "Email Us" ["id"]=>"24" array[2] ["account_id"] => "3" ["display_name"] => "Approver" ["id"]=>"54" and so on... Can anyone help?
[eluser]JRY[/eluser]
Pleaes try this <?php foreach ($myquery2->result() as key=>$row) { } ?>
[eluser]CroNiX[/eluser]
If you want an array returned, TELL IT! Code: //get the result as an array Also, if you are going to be using the result in javascript, it might be better to just json_encode() it. |
Welcome Guest, Not a member yet? Register Sign In |