$rs=$this->db->query("SELECT * FROM refermances ORDER BY refsort ASC");
$rs->result_array()
$data['rs']=$rs->result_array();
forearch($rs as $r){
$img=$this->db->query("SELECT * FROM reranceimage WHERE refid='".$r['refid']."');
$data['rt']=$img->result_array();
}
$this->load->view('referances',$data);
แต่ผลเขียนสไตล์นี้นะ
Code (PHP)
$sql1="SELECT * FROM refermances ORDER BY refsort ASC";
$list1=$this->db->query($sql1)->result_array();
$data['list1']=$this->db->query($sql1)->result_array();
forearch($list1 as $rs){
$sql2="SELECT * FROM reranceimage WHERE refid='".$rs['refid']."';
$list2=$this->db->query($sql2)->result_array();
$data['list2']=$this->db->query($sql2)->result_array();
}
$this->load->view('referances',$data);
forearch($list1 as $rs){
$sql2="SELECT * FROM reranceimage WHERE refid='".$rs['refid']."';
$list2=$this->db->query($sql2)->result_array();
foreach($list2 as $rs){
}
}