Welcome Guest, Not a member yet? Register   Sign In
Numerically Indexed Result Arrays?!?
#1

[eluser]Unknown[/eluser]
I’m still fairly new to CI, but I’m really lovin’ it so far.

My problem is—PHP has a way to retrieve records from tables with a numeric index but, apparently, CI does not. (At least not in the documentation I’ve read so far.)

Does anyone know how to get a numerically indexed (0 to whatever) array from a query result such as:
$res = $this->db->getwhere(‘contacts’,array(‘id’=>$id));

When I use: $row = $res->row_array();
I get an array that does not allow me to place field contents using:

... value=”<?=$row[0]?>” ...

Am I just converting to the row incorrectly or what?
Signature

gulp What the ..... red face
#2

[eluser]InsiteFX[/eluser]
Code:
$res = $this->db->getwhere(‘contacts’,array(‘id’=>$id));

foreach ($res->result() as $row)
{
    echo $row->id;
    // etc for other fields in the table
}

You should be using a model and return an array to your controller
then you can set the $data and pass it to your view!

If you show more of your code we can help you better.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB