標籤:
1 public function get_search($page=1){ 2 $slide=$_POST[‘slide‘]; 3 $page=trim($page); 4 $arr=$this->M->get_all("SELECT a.* FROM `lx_z_news` as a where a.`title` like ‘%".$slide."%‘ union all SELECT b.* from `lx_z_product` as b where b.`title` like ‘%".$slide."%‘ "); 5 $row=count($arr); 6 $page2=Page($page,$row,10); 7 $select_from=$page2[‘select_from‘]; 8 $select_limit=$page2[‘select_limit‘]; 9 $arr1=$this->M->get_all("SELECT ‘a‘ tbname,a.title,a.summary,a.id,a.c_time,a.status as thumb FROM `lx_z_news` as a where a.`title` like ‘%".$slide."%‘ union all SELECT ‘b‘ tbname,b.title,b.summary,b.id,b.c_time,b.thumb from `lx_z_product` as b where b.`title` like ‘%".$slide."%‘ limit $select_from,$select_limit ");10 11 foreach($arr1 as $key=>&$e){12 13 $e[‘title‘]=str_replace($slide, ‘<i style="color:red">‘.$slide.‘</i>‘, $e[‘title‘]);14 }15 unset($e);16 17 $this->assign("slide",$slide);18 $this->assign(‘search_list‘,$arr1);19 $this->assign(‘pagenav‘,$page2[‘pagenav‘]);20 $this->assign(‘num‘,$row);21 $this->display("search01.html");22 }
0:多表 union all 不去重 、、、、union 去重
1:‘a‘ tbname ,‘b‘ tbname 查出是哪個表的
2:查詢結果欄欄位必須相同
php sql 多表查詢 分頁