Welcome Guest, Not a member yet? Register   Sign In
passing name instead of id
#7

(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
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Movies_genre extends CI_Controller {
    function 
__construct()
    {
        parent::__construct();
        $this->load->model('Model_common');
        $this->load->model('Model_movie_genre');
        //$this->load->model('Model_portfolio');
    }

    public function 
index($genre_type=NULL)
    {
        
/*if( !isset($id) || !is_numeric($id) ) {
            redirect(base_url());
        }*/

        
$tot $this->Model_movie_genre->genre_check($genre_type);
        if(!
$tot) {
            
redirect(base_url());
        }


        
$data['general_settings'] = $this->Model_common->general_settings();
        
$data['page_movies_genre'] = $this->Model_common->page_movies_genre();
        
$data['social_settings'] = $this->Model_common->social_settings();
        
        
$data['movies_by_genre'] = $this->Model_movie_genre->movies_by_genre($genre_type);
        
$data['genre_by_name'] = $this->Model_movie_genre->genre_by_name($genre_type);

        
//$data['portfolio_footer'] = $this->Model_portfolio->get_portfolio_data();

        
$this->load->library('pagination');

        
$config = array();
        
$config['full_tag_open']    '<div class="pagging text-center"><nav><ul class="pagination">';
    
    $config['full_tag_close']   '</ul></nav></div>';
    
    $config['num_tag_open']     '<li class="page-item"><span class="page-link">';
    
    $config['num_tag_close']    '</span></li>';
    
    $config['cur_tag_open']     '<li class="page-item active"><span class="page-link">';
    
    $config['cur_tag_close']    '<span class="sr-only">(current)</span></span></li>';
    
    $config['next_tag_open']    '<li class="page-item"><span class="page-link">';
    
    $config['next_tag_close']  '<span aria-hidden="true"></span></span></li>';
    
    $config['prev_tag_open']    '<li class="page-item"><span class="page-link">';
    
    $config['prev_tag_close']  '</span></li>';
    
    $config['first_tag_open']   '<li class="page-item"><span class="page-link">';
    
    $config['first_tag_close'] = '</span></li>';
    
    $config['last_tag_open']    '<li class="page-item"><span class="page-link">';
    
    $config['last_tag_close']  '</span></li>';

        $config["base_url"] = base_url() . "movies/genre";
        $config["total_rows"] = $this->Model_movie_genre->movies_by_genre($genre_type);
        $config['first_url'] = base_url() . 'movies/genre';
        $config["per_page"] = 18;
        $config["uri_segment"] = 3;
        $config['use_page_numbers'] = TRUE;
        //$config['page_query_string'] = TRUE;

        $this->pagination->initialize($config);

        $offset = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $data['movies_fetched'] = $this->Model_movie_genre->movies_by_genre($genre_type$config["per_page"], $offset);
        $data["links"] = $this->pagination->create_links();


        
$this->load->view('view_header',$data);
        
$this->load->view('view_movies_genre',$data);
        
$this->load->view('view_footer',$data);
    }



Model page,

Model_movie_genre.php
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Model_movie_genre extends CI_Model 
{
    public function 
movies_by_genre($genre_type)
    {
        
$query $this->db->query("SELECT * FROM movies_info WHERE movie_genre=? ORDER BY movie_id DESC", array('movie_genre'=>$genre_type));
        return 
$query->result_array();
    }

    public function 
genre_by_name($genre_type)
    {
        
$query $this->db->query("SELECT * FROM genre_info WHERE genre_type=?", array('genre_type'=>$genre_type));
        return 
$query->first_row('array');
    }

    public function 
genre_check($genre_type) {
        
$sql 'SELECT * FROM genre_info WHERE genre_type=?';
        
$query $this->db->query($sql,array('genre_type'=>$genre_type));
        return 
$query->num_rows();
    }


View page,

view_movies_genre.php
PHP Code:
<!-- /w3l-medile-movies-grids -->
    <
div class="general-agileits-w3l">
        <
div class="w3l-medile-movies-grids">

                <!-- /
movie-browse-agile -->
                
                      <
div class="movie-browse-agile">
                         <!--/
browse-agile-w3ls -->
                        <
div class="browse-agile-w3ls general-w3ls">
                                <
div class="tittle-head">
                                
                                <
h4 class="latest-text">
                                    <?
php //echo $movies_by_genre['movie_id'];?> 
                                    <?php //echo $movies_by_genre->movie_id; ?>
                                    <?php //echo $genre_type; ?>
                                    <?php foreach($movies_by_genre as $row) { 
                                        echo 
$row->movie_id;
                                        }
                                        
?>
                                </h4>
                                    <div class="container">
                                        <div class="agileits-single-top">
                                            <ol class="breadcrumb">
                                            
                                              <li><a href="">Home</a></li>
                                              <li class="active" style="text-transform:Capitalize;">
                                                  <?php //echo $movies_by_genre['movie_genre'];?>
                                                  <?php //echo $genre_type; ?>
                                              </li>
                                            </ol>
                                        </div>
                                    </div>
                                </div>
                                     <div class="container">
                            <div class="browse-inner">
                                
                                <?php 
                            
foreach($movies_by_genre as $row) { 
                            
?>    
                               <div class="col-md-2 w3l-movie-gride-agile"> 
                                         <a href="<?php echo base_url(); ?>movie/<?php echo $row->movie_id?>" class="hvr-shutter-out-horizontal">
                                             <img src="<?php echo base_url(); ?>/public/images/movies/<?php echo $row->movie_image?>" title="<?php echo $row->movie_name?>" alt=" " />
                                         <div class="w3l-action-icon"><i class="fa fa-play-circle" aria-hidden="true"></i></div>
                                    </a>
                                      <div class="mid-1">
                                        <div class="w3l-movie-text">
                                            <h6><a href="<?php echo base_url(); ?>movie/<?php echo $row->movie_id?>">
                                                <?php echo $row->movie_name?></a></h6>                            
                                        </div>
                                        <div class="mid-2">
                                        
                                            <p><?php echo $row->release_year?></p>
                                            <div class="block-stars">
                                                <ul class="w3l-ratings">
                                                         
                                                         <li> 
                                                          <span>IMDB <i class="fa fa-star" aria-hidden="true"></i> 
                                                              <?php echo $row->movie_rating?> 
                                                          </span>
                                                         </li>
                                        
                                                </ul>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                            
                                    </div>
                                     <div class="ribben two">
                                        <p>NEW</p>
                                    </div>    
                                    </div> 
                                    <?php ?>
                                    
                                    <div class="clearfix"> </div>
                                </div>
                                
                            
                                </div>
                        </div>
                <!--//browse-agile-w3ls -->
                        <!-- <div class="blog-pagenat-wthree">
                            <ul>                                        
                                    
                                    <?php
                                    
// display the links to the pages
                                    //for($page=1;$page<=$number_of_pages;$page++){
                                        //echo '<a href="movies.php?page=' . $page . '">' . $page . '</a> ';
                                    
                                /* <li><a class="frist" href="#">Prev</a></li> */
                                    /*echo '<li><a href="movies-genre.php?genre_type='.$_REQUEST['genre_type'].'&page=' . $page . '">' . $page . '</a></li>';
                                }*/
                                    
?> -->
                                <!--<li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li><a class="last" href="#">Next</a></li> -->
                        <!--    </ul>
                        </div>
                    </div> -->

                    <?php echo $links?>

                    <!-- //movie-browse-agile -->
                
        </div>
    <!-- //w3l-medile-movies-grids -->
    </div>
    <!-- //comedy-w3l-agileits --> 
Reply


Messages In This Thread
passing name instead of id - by manigopal - 10-23-2019, 08:39 PM
RE: passing name instead of id - by Wouter60 - 10-24-2019, 05:05 AM
RE: passing name instead of id - by manigopal - 10-24-2019, 05:31 AM
RE: passing name instead of id - by Wouter60 - 10-24-2019, 06:26 AM
RE: passing name instead of id - by manigopal - 10-25-2019, 10:26 AM
RE: passing name instead of id - by manigopal - 10-25-2019, 07:58 PM
Added Pagination - by manigopal - 10-25-2019, 11:59 PM
RE: passing name instead of id - by Wouter60 - 10-26-2019, 01:30 AM
RE: passing name instead of id - by manigopal - 10-26-2019, 01:44 AM
RE: passing name instead of id - by Wouter60 - 10-26-2019, 01:58 AM
RE: passing name instead of id - by manigopal - 10-26-2019, 02:01 AM
RE: passing name instead of id - by Wouter60 - 10-26-2019, 02:30 AM
RE: passing name instead of id - by manigopal - 10-26-2019, 07:18 AM
RE: passing name instead of id - by Wouter60 - 10-26-2019, 08:48 AM
RE: passing name instead of id - by manigopal - 10-26-2019, 09:02 AM
RE: passing name instead of id - by manigopal - 10-26-2019, 10:24 PM
RE: passing name instead of id - by manigopal - 10-27-2019, 01:07 AM
RE: passing name instead of id - by Wouter60 - 10-27-2019, 04:48 AM
RE: passing name instead of id - by manigopal - 10-27-2019, 07:16 AM
RE: passing name instead of id - by Wouter60 - 10-27-2019, 07:44 AM
RE: passing name instead of id - by manigopal - 10-27-2019, 08:04 AM
RE: passing name instead of id - by manigopal - 10-28-2019, 03:27 AM
RE: passing name instead of id - by Wouter60 - 10-28-2019, 10:50 AM
RE: passing name instead of id - by manigopal - 10-28-2019, 10:21 PM
RE: passing name instead of id - by wdeda - 12-28-2019, 05:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB