Loading ...
Sorry, an error occurred while loading the content.

codeigniter pagination problem

Expand Messages
  • Syed Rajib Rahman
    i am facing problem in CI pagination class... here is my model: test_model.php class Test_model extends Model { function Test_model() { parent::Model();
    Message 1 of 1 , Oct 31, 2008
    • 0 Attachment
      i am facing  problem in CI pagination class...

      here is my model: test_model.php
         
          class Test_model extends Model
              {
          function Test_model()
                   {
                   parent::Model();
                   $this->load->database();
                       session_start();
                   }    
                  
                   function get_submenu($num,$offset,$id)
                      {
                          
                      $this->db->select('*');
                       $this->db->from('inbook_special_phase_details');
                        $this->db->where('cat_id', $id);
                        $query = $this->db->get();
                           return $query;
                       }
                                  function get_nrows($num,$offset,$id)
                      {
                          
                      $this->db->select('*');
                       $this->db->from('inbook_special_phase_details');
                        $this->db->where('cat_id', $id);
                        $query = $this->db->get();
                        $n=$query->num_rows();
                         return $n;
                                  }    
      }                        
      =====================================================================
      My Controller....:  Group12_Business


       class Group12_Business extends Controller
              {
              
                function Group12_Business()
                    {
                   parent::Controller();
                   $this->load->helper(array('xml','url'));
                   $this->load->library('pagination');
                      $this->load->library('table');
                   }
                  
                function special_menu($id)
                  {        
                           $a=$this->test_model->get_nrows('3',$this->uri->segment(3),$id);
                           $_SESSION['cat_id'] = $id;
                          $this->load->model('test_model');
                          $config['base_url'] = base_url().'index.php/Group12_Business/special_menu/';
                          $config['total_rows'] = $a;
                          $config['per_page'] = '3';
                            $config['full_tag_open'] = "<div id='pagination'>";
                           $config['full_tag_close'] = '</div>';
          
                          $this->pagination->initialize($config);
                  
                                             $data=array();
                                            $data['results'] = $this->test_model->get_submenu($config['per_page'],$this->uri->segment(3),$id);  
                   
                          
                $this->load->view('view_special_menu_details',$data);  
                   }
                   }
              ==============================================================================
      View file:  'view_special_menu_details.php

       <table width="900" height="380" border="0">
              <tr align="left">
                <td height="10" colspan="3" align="center"><u><span class="style1">Special Menu Items</span></u></td>
              </tr>
              <?php
                 $i=0;
               foreach($results->result_array() as $row)
              {   
                  $i++;
           ?>
              <tr>
                <td width="158"><DIV ID="right_special_menu_list" align="left">&nbsp;&nbsp;&nbsp;&nbsp; <font color="#009900" face="tahoma" size="+1">Menu</font>
                    <DIV ID="left_sub_menu"> <a href="<?=base_url()?>index.php/Group12_Business/special_menu/1/" style="text-decoration:none;"><font color="#fd7700" face="tahoma" size="2">Today‚Äôs Top media</font></a> <br />
                      <a href="<?=base_url()?>index.php/Group12_Business/special_menu/2/" style="text-decoration:none;"><font color="#fd7700" face="tahoma" size="2">Service</font></a> <br />
                      <a href="<?=base_url()?>index.php/Group12_Business/special_menu/3/" style="text-decoration:none;"><font color="#fd7700" face="tahoma" size="2">Bussiness</font></a><br />
                      <br />
                    </DIV>
                  </DIV></td>



                <td width="82" valign="top" align="center">&nbsp;&nbsp; <a href="<?=base_url()?>assets/images/<? echo $row["image_file"];?>" title="<? echo $row["photo_caption"];?>"
            rel="sexylightbox[galleries]"> <img src="<?=base_url()?>assets/images/<? echo $row["image_file"];?>" width="66" height="65" border="0"/></a> <br />
                  <u>
                  <?
          echo $row["photo_caption"];?>
                  </u> </td>
                <td width="598" valign="top" align="left"><p align="left"> <font color="#fd7700" face="tahoma" size="2"><b>
                    <?   
          echo $row["subject"];?>
                    </b></font> <br />
                    <br />
                    <? echo $row["details"];?> <br />
                    <br />
                    <br />
                  <hr />
                  </p></td>
                <td width="44"></td>
              </tr>
              <tr></tr>
              <? } ?>
              <tr>
              
            </table>
            <div id="pagination" style="position:relative;margin-left:400px;margin-top:10px;">
           
                <?php $this->table->generate($results); ?>
                
      <table border="0">
        <tr nowrap="nowrap">
          <td> <img src="<?=base_url()?>assets/images/inbooo.gif"/></td>
          <td  nowrap="nowrap"><?php echo $this->pagination->create_links(); ?></td>
          <td>
            <img src="<?=base_url()?>assets/images/k.gif"/></td>
        </tr>
      </table>


      ==========================================================================

      SQL:

      CREATE TABLE `inbook_special_phase_category` (
        `cat_id` int(11) NOT NULL auto_increment,
        `category_name` varchar(20) collate latin1_general_ci NOT NULL,
        `category_icon` varchar(150) collate latin1_general_ci NOT NULL,
        PRIMARY KEY  (`cat_id`),
        UNIQUE KEY `cat_id` (`cat_id`)
      ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=28 ;

      --
      -- Dumping data for table `inbook_special_phase_category`
      --

      INSERT INTO `inbook_special_phase_category` VALUES
      (1, 'Media', 'media-icon.png'),
      (2, 'Services', 'services.png');

      CREATE TABLE `inbook_special_phase_details` (
        `content_id` int(11) NOT NULL auto_increment,
        `cat_id` int(11) NOT NULL,
        `subject` varchar(145) collate latin1_general_ci NOT NULL,
        `details` varchar(200) collate latin1_general_ci NOT NULL,
        `image_file` varchar(150) collate latin1_general_ci NOT NULL,
        `photo_caption` varchar(25) collate latin1_general_ci NOT NULL,
        PRIMARY KEY  (`content_id`),
        UNIQUE KEY `content_id` (`content_id`)
      ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=42 ;

      --
      -- Dumping data for table `inbook_special_phase_details`
      --

      INSERT INTO `inbook_special_phase_details` VALUES
      (41, 1, 'special events 3', 'special events 3 details', 'test.jpg', 'special events 3'),
      (1, 2, 'Special Events', 'Specials Events details', 'bachman.jpg', 'bachman'),
      (38, 1, 'test2', 'sunset details', '1.jpg', 'sunset'),
      (39, 1, 'test3', 'water fall details', '2.jpg', 'water fall'),
      (40, 1, 'special events 2', 'special events details', 'test.jpg', 'special events 2');


    Your message has been successfully submitted and would be delivered to recipients shortly.