Welcome Guest, Not a member yet? Register   Sign In
Query problems
#4

[eluser]Laranjeiro[/eluser]
I have found the solution.

The problem wasn't that complicated. I am just not used to CI yet.

What I wanted to do was when I clicked the journal link, it appear the last submitted information.
I solved it like

Code:
// last headline
        $this->db->select_max('id');
        $query = $this->db->get('journal');

        foreach ($query->result() as $row):
            $last = $row->id;
        endforeach;

        $this->db->where('id',$last);
        $data['query2'] = $this->db->get('journal');

For the headlines list

Code:
// headlines
        $this->db->select('title,id');
        $this->db->from('journal');
        $this->db->order_by("id", "desc");
        $data['query'] = $this->db->get();

For the selected headline
Code:
//selected headline
        $this->db->where('id',$this->uri->segment(3));
        $data['query2'] = $this->db->get('journal');

I divide it in two functions. One that would show the last inserted item and another for the selected item.
And that's it.

Thanks for all the help


Messages In This Thread
Query problems - by El Forum - 02-17-2009, 12:33 PM
Query problems - by El Forum - 02-17-2009, 01:13 PM
Query problems - by El Forum - 02-17-2009, 01:14 PM
Query problems - by El Forum - 02-17-2009, 01:42 PM
Query problems - by El Forum - 02-17-2009, 01:50 PM
Query problems - by El Forum - 02-17-2009, 06:14 PM
Query problems - by El Forum - 02-17-2009, 06:29 PM
Query problems - by El Forum - 02-17-2009, 06:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB