[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: <?=$info->title; ?></h2>
<h3>Directed by: <?=$info->director_1; ?><? if($info->director_2) { echo ", $info->director_2";} ?></h3>
What I get is, the code after $info being printed entirely:
director_2) { echo ", $info->director_2";}; ?>
Can someone help me?