I'm working on CodeIgniter I'm calling two result()
and I want to buy the data in the view.
Model
public function getallData()
{
$this->db->order_by('id', 'desc');
$query = $this->db->get('Data');
if ($query->num_rows() > 0) {
return $query->result();
} else { return false; }
}
public function getWhere($id)
{
$query = $this->db->get_where('Table', array(
'status' => $id
));
if ($query->num_rows() > 0) {
return $query->result();
}
}
Controller
public function index()
{ $status = 'On';
$data['datos']=$this->m->getallData();
$data['tecnicos']=$this->m->getWhere($status);
$this->load->view('list',$data);
}
I have this view but I repeat the data: /
<?php if ($datos): ?>
<?php foreach ($datos as $dato): ?>
<?php foreach ($tecnicos as $tecnico): ?>
<?php if ($dato-> id == $tecnico-> id_tec): ?>
<?php echo 'H'; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
I hope you have explained me well