0
即時通訊功能,將顯示購買和出售清單。我試圖在一個頁面中顯示這兩個。 即時通訊從2個不同的表中獲取值,我想通過這兩個值到相同的模板從2個表格傳遞值到一個視圖codeigniter
有人可以請建議如何做到這一點?
控制器
function leads(){
$this->load->model('listings');
$data['mylists']=$this->member_functions->mine();
$data['mylists2']=$this->member_functions->mine();
$data['heading']='headings/heading_view';
$data['body']='listbody';
$data['nav']='right';
$this->load->view('includes/template',$data);
}
型號
function mine(){
$mylists=$this->db->get('buy');
if ($mylists->num_rows()>0){
foreach ($mylists->result() as $a)
{
$data[]=$a;
}
return $data;
}
$mylists2=$this->db->get('sell');
if ($mylists2->num_rows>0)
{
foreach ($mylists->result() as $b)
{
$data[]=$b;
}
return $data;
}
}
查看
<h2>Buy leads</h2>
<?php foreach ($mylists as $mylist):?>
<p><?php echo "$mylist->type1 in $mylist->country as $mylist->buyid" ?></p>
<?php endforeach;?>
</div>
<br />
<h2>Sell leads</h2>
<?php foreach ($mylists2 as $mylist2):?>
<p><?php echo "$mylist2->type1 in $mylist2->country" ?></p>
<?php endforeach;?>