Welcome Guest, Not a member yet? Register   Sign In
Can you insert an if condition in a view file?
#1

[eluser]titanite[/eluser]
Hi guys,

I'm really new at this, so please be patient with me. :cheese:

I'm doing up a movie database, and I have a page which has all the listings of the movie names. By clicking on Read More, one arrives at the full movie review.

This is my controller, which I name movie.php.

Code:
class Movie extends Controller {

    function Movie()
    {
        parent::Controller();
    }

    function movie_review()
    {
        $this->load->model('Movie_model');
        $id = $this->uri->Segment(3);
        $data['info'] = $this->Movie_model->get_review($id);
        $this->load->view('movie_view', $data);
    }
}

This is my Model, which I use to retrieve all information about a movie, which I call movie_model.php

Code:
class Movie_model extends Model {

    function Movie_model()
    {
        parent::Model();
    }

    function get_review($id)
    {
        $this->db->where('id', $id);
        $q = $this->db->get('movie_review');
        $info = $q->row();
        return $info;
    }

}

Now comes my view file. The issue is, I'd like to display a co-director IF he exists. But the IF condition just does not work.

Code:
<h2>Title: &lt;?=$info->title; ?&gt;</h2>
<h3>Directed by: &lt;?=$info->director_1; ?&gt;&lt;? if($info->director_2) { echo ", $info->director_2";} ?&gt;</h3>

What I get is, the code after $info being printed entirely:

director_2) { echo ", $info->director_2";}; ?&gt;

Can someone help me? Undecided


Messages In This Thread
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 03:48 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 06:34 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 06:40 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 06:41 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 06:46 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 06:58 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 10:18 AM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 12:40 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 01:11 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 01:13 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 01:17 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 01:18 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 01:59 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 02:02 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 02:02 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 02:04 PM
Can you insert an if condition in a view file? - by El Forum - 04-18-2010, 09:38 PM
Can you insert an if condition in a view file? - by El Forum - 04-19-2010, 11:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB