passing name instead of id |
Hi all,
I'm doing project for movies based website, i need to pass the genre_type instead of instead of ID. Web URL : showtime (dot) 22web(dot) org - and menu Movies Genre. Objective : to get the movies list based on selected genre with Pagination ., i have done it using core PHP @ showtime (dot) 22web(dot) org/movies-genre.php?genre_type=Action My code, @ https://gitlab.com/manigopal/ci-projects...r/Showtime [regularly updated after every changes] Live Website @ http://cishowtime.22web.org Pagination works fine on #Movies page @ http://cishowtime.22web.org/movies Resource files of #Movies page : Model file => Model_movie.php View file => view_movies.php Controller file => Movies.php Issue on #MoviesGenre page @ http://cishowtime.22web.org/movies/genre/Action Resource files of #MoviesGenre page : Model file => Model_movie_genre.php View file => view_movies_genre.php Controller file => Movies_genre.php MVC files of Movies(which works fine) & MoviesGenre(which has issue) @ https://gitlab.com/manigopal/ci-projects...r/Showtime
Your route should be:
PHP Code: $route['movies/genre/(:any)'] = 'movies_genre/index/$1'; Wouldn't it be more simple if you just named your controller "Movies.php" with a function genre inside it that takes the $movie_genre as parameter? Then you don't need a route at all.
is this correct to pass the value ?
@Controller (Movies_genre.php) : following lines only, public function index($genre_type=NULL) $data['movies_by_genre'] = $this->Model_movie_genre->movies_by_genre($genre_type); I have Error received : A PHP Error was encountered Severity: Notice Message: Undefined index: movie_genre Filename: views/view_movies_genre.php Line Number: 13 Backtrace: File: C:\xampp\htdocs\ciprojects\showtime\application\views\view_movies_genre.php Line: 13 Function: _error_handler File: C:\xampp\htdocs\ciprojects\showtime\application\controllers\Movies_genre.php Line: 36 Function: view File: C:\xampp\htdocs\ciprojects\showtime\index.php Line: 315 Function: require_once A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: views/view_movies_genre.php Line Number: 14 Backtrace: File: C:\xampp\htdocs\ciprojects\showtime\application\views\view_movies_genre.php Line: 14 Function: _error_handler File: C:\xampp\htdocs\ciprojects\showtime\application\controllers\Movies_genre.php Line: 36 Function: view File: C:\xampp\htdocs\ciprojects\showtime\index.php Line: 315 Function: require_once
10-25-2019, 11:59 PM
(This post was last modified: 10-26-2019, 12:04 AM by manigopal. Edit Reason: Added Pagination )
After adding Pagination to controller file,
Movies_genre.php PHP Code: <?php Model page, Model_movie_genre.php PHP Code: <?php View page, view_movies_genre.php PHP Code: <!-- /w3l-medile-movies-grids -->
Your model returns $query->result_array();
The result is an array with each record as an associative array. To address an element in this array, you have to use: PHP Code: $row['genre_type'] If your model would return $query->result(); then each record as an object. Elements are then addressed by: PHP Code: $row->genre_type
Hi @Wouter60
i have also added #pagination does this is right ? ; $data['movies_fetched'] = $this->Model_movie_genre->movies_by_genre($genre_type, $config["per_page"], $offset); An uncaught Exception was encountered Type: Error Message: Unsupported operand types Filename: C:\xampp\htdocs\ciprojects\showtime\system\libraries\Pagination.php Line Number: 412 Backtrace: File: C:\xampp\htdocs\ciprojects\showtime\application\controllers\Movies_genre.php Line: 64 Function: create_links File: C:\xampp\htdocs\ciprojects\showtime\index.php Line: 315 Function: require_once Quote:Backtrace: What is on line 64 of your controller? |
Welcome Guest, Not a member yet? Register Sign In |