codeidniter 19 урок
0
Выдает ошибку когда в блоке
if ($slug = "movies") {
$this->data['title'] = "Фильмы";
$this->data['movie_data'] = $this->films_model->getFilms(false, 10, 1);
}
После $slug ставлю ==
Ошибка :
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: movies/type.php
Line Number: 4
Backtrace:
File: C:\xampp\htdocs\kinomonster\application\views\movies\type.php
Line: 4
Function: _error_handler
File: C:\xampp\htdocs\kinomonster\application\controllers\Movies.php
Line: 29
Function: view
File: C:\xampp\htdocs\kinomonster\index.php
Line: 315
Function: require_once
Код :
1)Movies.php
public function type($slug = NULL) {
$this->data['movie_data'] = null;
if ($slug == "movies") {
$this->data['title'] = "Фильмы";
$this->data['movie_data'] = $this->films_model->getFilms(false, 10, 1);
}
if ($slug == "serials") {
$this->data['title'] = "Сериалы";
$this->data['movie_data'] = $this->films_model->getFilms(false, 10, 2);
}
/*if ($this->data['movie_data'] == null) {
show_404();
}*/
$this->load->view('templates/header', $this->data);
$this->load->view('movies/type', $this->data);
$this->load->view('templates/footer');
}
2)type.php
<h3><?php echo $title; ?></h3>
<hr>
<?php foreach ($movie_data as $key => $value): ?>
<div class="row">
<div class="well clearfix">
<div class="col-lg-3 col-md-2 text-center">
<img class="img-thumbnail" src="<?php echo $value['poster']; ?>" alt="<?php echo $value['name']; ?>">
<p><?php echo $value['name']; ?></p>
</div>
<div class="col-lg-9 col-md-10">
<p>
<?php echo $value['descriptions']; ?>
</p>
</div>
<div class="col-lg-12">
<a href="/movies/view/<?php echo $value['slug']; ?>/" class="btn btn-lg btn-warning pull-right">Подробнее</a>
</div>
</div>
</div>
<?php endforeach ?>