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?
#2

[eluser]mk3[/eluser]
Do u return results from model...??? Smile what I'm always using echo to debug my code on results...
and I believe that u should get numeric array.

It seems i have found your problem u are using wrong function maybe here is mine for example returns numeric arrays with no problem:
Code:
function dologin($username, $password){
        $this->db->where('user', $username);
        $this->db->where('password', $password);
        $this->db->where('active', 1);
        $query = $this->db->get('members');
        if ($query->num_rows() > 0){
            return $query->result_array();
    
        }
It's taken from methods... also there is no such important thing as mysql escape... but the code is still beta Big Grin

it returns results in array[$i]['id']
#3

[eluser]Unknown[/eluser]
Thanks mk3,

I'll use the result_array() function in my next attempt.

I appreciate the quick response. Things are so much friendlier here!!!!




Theme © iAndrew 2016 - Forum software by © MyBB