Hello everyone.

Here just page refresh Counter++.

    $this->db->select('Counter_field');
    $this->db->where('id', $id); 
    $cnt = $this->db->get('Job_Description');


    $new_cnt = $cnt+1;


    $data = array('Counter_field'=>$new_cnt);
    $this->db->where('id',$id);
    $query = $this->db->update('Job_Description',$data);

What is wrong with above Query..
Every time i want increment and go to update results store in DB.

Try to use the row() method:

$row = $cnt->row();
$new_cnt = $row->Counter_field + 1;

But you could also run a single query:

$this->db->query("UPDATE Job_Description SET Counter_field = Counter_field + 1 WHERE id = ?", array($id));

Docs:

commented: @Cereal : Thank You. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.