Welcome Guest, Not a member yet? Register   Sign In
Have problems with displaying data from database
#1

Can someone help me , I'm still new with CodeIgniter , I have problems in displaying data from database in another page because I am confused with controller either I should put on the function on default controller or made a new one, and if I made a new one, I don't know how to call the function to display the data from database on another page. 

this is my default controller : 

PHP Code:
<?php 

class Pages extends CI_Controller{
 
   public function __construct(){
 
       parent::__construct();
 
       $this->load->helper('url');
 
   }


    public function 
view($page 'home')
    {
        if ( ! 
file_exists(APPPATH.'/views/pages/'.$page.'.php'))
    {
        
// Whoops, we don't have a page for that!
        
show_404();
    }

    
$data['title'] = ucfirst($page); // Capitalize the first letter

    
$this->load->view('templates/header'$data);
    
$this->load->view('pages/'.$page$data);
    
$this->load->view('templates/footer'$data);

    }

public function 
GetAll(){
 
   $data['all_data'] = $this->exhibitions_model->selectAllData();
 
   $this->load->view('exhibitons'$data);
}

}

?>

and this is my model : 

PHP Code:
<?php
       
public function selectAllData() {
 
       $query $this->db->get('omg_events');
 
       return $query->result();
 
   }
?>


and the page that I want to display data from the database :

Code:
<head>
   <link href="<?php echo base_url() ?>css/about.css" rel="stylesheet">
</head>

<!--==========================
   Intro Section
 ============================-->

 <section id="intro">
   <div class="intro-container">
     <div id="introCarousel" class="carousel  slide carousel-fade" data-ride="carousel">


       <div class="carousel-inner" role="listbox">

         <div class="carousel-item active">
            <div class="carousel-background"><img src="<?php echo base_url() ?>img/events.jpg" alt=""></div>
           <div class="carousel-container">
             <div class="carousel-content">
               <h2>Exhibitions</h2>
             </div>
           </div>
         </div>

     </div>
   </div>
 </section><!-- #intro -->

 <main id="main">

   
   <!--==========================
     Team Section
   ============================-->
   <section id="team">
     <div class="container">
       <div class="section-header wow fadeInUp">
         

       <div class="album py-5 bg-light">
   <div class="container">

      <div class="section-header">
         <h3>EXHIBITIONS ROADSHOWS & SEMINAR</h3>
         <p></p>
       </div>

<table class="table table-hover">

 <thead>
   <tr>
   

   </tr>
 </thead>
 <tbody>
<?php

   foreach ($all_data as $show):
       ?>

   <tr>
     <th scope="row"><?php echo $show->event_id?></th>
     <td width="10%"><?php echo $show->name?></td>
     <td width="10%"><?php echo $show->address?></td>
     <td></td>
     <td></td>
     <td width="15%""><a href="">Send Enquiry</a></td>
   </tr>
  <?php

   endforeach;
   ?>
 </tbody>
</table>
     
     
     </div>

   </section><!-- #team -->


 
 </main>
Reply


Messages In This Thread
Have problems with displaying data from database - by firas - 01-27-2019, 10:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB