01-07-2013, 03:34 AM
[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:
and heres my model:
heres my view:
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="<?php echo base_url(); ?>/images/templates/<?php echo $image; ?>" alt="Simple and Clean Template">
<div class="panel">
<h5><?php echo $name; ?></h5>
<h6 class="subheader"><?php echo $type; ?><span class="right"><a href="templates/fresh-and-clean.php">Detail</a></span></h6>
</div>
</div>