EllisLab text mark
Advanced Search
     
call single data table from sql in CI
Posted: 27 September 2012 11:42 PM   [ Ignore ]
Avatar
Joined: 2012-09-27
2 posts

Hai im newbie in codeigniter

to all CI master i want to ask how to call a single data sql from controller model to views

here is my controller

public function about(){
  $data
=array();
        
        
$this->load->model('admin_model');
        
$row $this->admin_model->about();
        
        
$data['description']$row;
       
  
$this->load->view('header_admin',$data);
  
$this->load->view('about',$data);
  
$this->load->view('footer_admin');
 

and here is my model

public function about(){
        $sql 
'select * from about where id = 1; ';
        
$query $this->db->query($sql);
        return 
$query;
 

and this is my view

<body>
<
div>
 
<?php echo $row['description']?>
</div>
</
body

all i want is to view my description row table in about table database

thank u for your help smile

 
Posted: 28 September 2012 06:16 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2009-04-30
76 posts
public function about()
{
        $sql 
'select * from about where id = 1; ';
        return 
$this->db->query($sql)->row_array();

http://ellislab.com/codeigniter/user-guide/database/results.html

 
Posted: 28 September 2012 06:17 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2012-09-27
2 posts

Thank u smile