• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help on how to loop .. displaying all data on database..

#1
[eluser]besingamk[/eluser]
hi im new on codeigniter and i cant loop this one.. please help me.
all i need is to loop the codes as long as it has data on database

heres my controler:
Code:
public function homepage()
{
  $this->load->model("get_db_home");
  $data['result'] = $this->get_db_home->getData();
  $data['title'] = "Home";
  $this->load->view("template/header", $data);
  $this->load->view("sample", $data);
  $this->load->view("template/footer");
}

and heres my model:
Code:
<?php

class Get_db_home extends CI_Model
{
function getData(){
  $query = $this->db->query("SELECT * FROM table WHERE id = id ORDER by id DESC");
  return $query->result();
}
}

heres my view:
Code:
<?php

foreach($result as $row){
$name = $row->name;
$image = $row->image;
$type = $row->type;

}


?>
// the code below is the one i want to loop

<div class="eight columns">
          <div class="row">

            <div class="four mobile-two columns">
              <img src="&lt;?php echo base_url(); ?&gt;/images/templates/&lt;?php echo $image; ?&gt;" alt="Simple and Clean Template">

              <div class="panel">
                <h5>&lt;?php echo $name; ?&gt;</h5>
                <h6 class="subheader">&lt;?php echo $type; ?&gt;<span class="right"><a href="templates/fresh-and-clean.php">Detail</a></span></h6>
              </div>
            </div>


Messages In This Thread
help on how to loop .. displaying all data on database.. - by El Forum - 01-07-2013, 03:34 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.