Welcome Guest, Not a member yet? Register   Sign In
Mysql Results Conditional
#1

[eluser]bunoire14[/eluser]
Hey Guys,

I've just picked up the framework for a project im working on. The idea is for a Flight Simulator Training Website that lists training courses being offered by various members, other members can then apply to take part..... basically...although a little more complex.

To begin with i have been watching some of the beginners tutorials from the wiki page, and since my previous PHP expereince has all been procedural, im trying to get my head round this MVC theory.

For the most part i have sussed it out and thanks to some great tutorial vids, managed to get the basics of my forward facing site in place.

I am however struggling with one area.... I have a page that simply querys MYSQL and gets all the information for the instructors from the DB. It then tables that info into a roster. The DB Table holds personal info, name, etc, but also the areas of training the staff member is allowed to teach. This info is stored as a BOOLEAN value on the DB, so when its pulled in the puery and displayed on the table I simply get a few rows of 1's or 0's... which is fine. What I would like to do is put a conidtional into the system somewhere that basically says if the result is 1 then display tick.gif, if the result is 0 display cross.gif... in essence to display images on the table not the raw 1's and 0's.

Now using the MVC methodology I'd expect that this would be done in the Controller? since its not exactly a DB query as much as it doing something with a result...however Its also dealing with how the data is formatted and displayed so could it also be done in the view?

Any help on where i should do this would be great, also suggestions on how to achieve it would be handy as I'm still trying to get my head round MVC and the different syntax used here.


Heres my Controller Method

Code:
//Site Staff Page Method
        function staff()
        {
            $this->load->model('staff_model');
            $data['staff_records'] = $this->staff_model->getStaff();
            $this->load->view('site_head');
            $this->load->view('staff', $data);
            $this->load->view('site_foot');
        }

Heres my Model

Code:
//Staff Model

class Staff_model extends Model{

    function getStaff()
    {
        $query = $this->db->query('SELECT * FROM staff ORDER BY callsign ASC');
        if($query->num_rows() >0){
        foreach($query->result() as $row)
        {
            $data[] = $row;
        }
        return $data;
        }
    }
}


Messages In This Thread
Mysql Results Conditional - by El Forum - 12-22-2010, 10:31 AM
Mysql Results Conditional - by El Forum - 12-22-2010, 11:11 AM
Mysql Results Conditional - by El Forum - 12-22-2010, 11:19 AM
Mysql Results Conditional - by El Forum - 12-22-2010, 09:26 PM
Mysql Results Conditional - by El Forum - 12-22-2010, 09:51 PM
Mysql Results Conditional - by El Forum - 12-23-2010, 08:26 AM
Mysql Results Conditional - by El Forum - 12-26-2010, 07:52 AM
Mysql Results Conditional - by El Forum - 12-26-2010, 07:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB