i have a beginner question.
Im making a video site.
I store the data in my database about the videos.
And i have a bit of a problem.
I would like to load the video embed by title and im doing something wrong.
the model
function load_video()
{
$q = $this->db->get_where('videos', array('title' => $title), 1);
if($q->num_rows() > 0) {
foreach($q->result() as $row) {
$vids[] = $row;
}
return $vids;
}
} 开发者_如何学Go
here is the main page view, and the anchore wich i sopose to click it would show the video
foreach ($results as $r) {
echo '<div class="video_box">';
echo '<p>' . substr($r->title, 0, 16) . "..." . " </p>";
$thumbnail = array('src' => $r->thumbnail, 'title' => $r->title,);
echo "<a href='index.php/video/play/".$r->title."'>" . img($thumbnail) . "</a>";
echo '<div class="duration">'.(round($r->duration / 60)).':' . ''.(round($r->duration % 60)).'</div>';
echo '</div>';
}
?>
and here is the video controller
function play($title){
$this->load->model('video_model');
$data['results'] = $this->video_model->load_video();
$this->load->view("video_page", $data);
}
and im always getting this error
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: title
Filename: models/video_model.php
Line Number: 49
could please someone point out what im doing wrong?
You dont load the variable/string inside your model?
If you use it in your database query yo should also send it? :)
In controller send it to model:
$this->video_model->load_video($title);
In model we include it in the function:
function load_video($title)
精彩评论