Welcome Guest, Not a member yet? Register   Sign In
Can't retrieve all records from database [SOLVED]
#1

[eluser]alrightythen[/eluser]
Hi

I'm developping a web site where I display all rows from a database on one of the pages.

Now when I add records everything is fine, the new record displays on the page.

But when I delete one and then add one record the last record does not display on the page. I've done some testing and apparently the retrieving stops when the id is not equal to the previous id+1.

So let's say I have a table Items with the following rows.

item_ID | item_Name | item_Description
----------------------------------
1 | item one | cool item!
2 | item two | awesome item!
5 | item five | ids 3 & 4 deleted

The page would only display items one and two. And not item five. So from now on the page will always display the first two items and not the whole table.

Does someone know what I'm doing wrong here?

This is my controller
Code:
if($q = $this->start_model->get_records())
{
    $data['records'] = $q;
}

$this->load->view('display_view', $data);


My model
Code:
function get_records(){
    $this->db->select('*');
    $this->db->from('items');
    $this->db->join('subcategories', 'categories.cat_ID = items.item_ID');
        
    $q = $this->db->get();
    $table_row_count = $this->db->count_all('items');

    if($q->num_rows() > 0){

        //echo $q->num_rows();
        //echo '<br/>';
        //echo $table_row_count;

        foreach ($q->result() as $row){
                $data[] = $row;
        }
        
        return $data;
    }
}


Messages In This Thread
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 08:51 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 09:04 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 09:25 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 09:39 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 09:56 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 09:57 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 10:00 AM
Can't retrieve all records from database [SOLVED] - by El Forum - 11-05-2009, 10:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB