diff --git a/application/third_party/recommend/controllers/index.php b/application/third_party/recommend/controllers/index.php index 3f492382..1e522d1a 100644 --- a/application/third_party/recommend/controllers/index.php +++ b/application/third_party/recommend/controllers/index.php @@ -31,9 +31,10 @@ class Index extends CI_Controller { $keywords = $this->input->post('keywords'); + $byWhat = $this->input->post('byWhat'); $data = array(); $data['groupList'] = $this->Information_model->group_list(); - $data['tipsList'] = $this->infoTips_model->search($keywords); + $data['tipsList'] = $this->infoTips_model->search($keywords, $byWhat); $this->load->view('bootstrap3/header', $data); $this->load->view('welcome'); $this->load->view('bootstrap3/footer'); diff --git a/application/third_party/recommend/models/infoTips_model.php b/application/third_party/recommend/models/infoTips_model.php index f1038264..8e2b01fe 100644 --- a/application/third_party/recommend/models/infoTips_model.php +++ b/application/third_party/recommend/models/infoTips_model.php @@ -57,17 +57,13 @@ class infoTips_model extends CI_Model } // keyword 可以是标题或者 URL,使用空格分开 - public function search($keywords) { - $keywordList = explode(" ", $keywords); - $whereCodition = ' and ('; - foreach ($keywordList as $index => $keyword) { - if ($index > 0) { - $whereCodition .= " or "; - } - $whereCodition .= "it.it_title like '%" . $keyword . "%'"; - } - foreach ($keywordList as $index => $keyword) { - $whereCodition .= " or it.it_content like '%" . $keyword . "%'"; + public function search($keywords, $byWhat) { + if ($byWhat == 'byTitle') { + $whereCodition .= " and it.it_title like '%" . $keyword . "%'"; + } else if ($byWhat == 'byLabel') { + $whereCodition .= " and it.it_code like '%" . $keyword . "%'"; + } else if ($byWhat == 'byContent') { + $whereCodition .= " and it.it_content like '%" . $keyword . "%'"; } $searchText = "select it.it_id ,it.it_title,it.it_expires,it.it_code,it.it_content,it.it_sitecode,it.it_datetime diff --git a/application/third_party/recommend/views/welcome.php b/application/third_party/recommend/views/welcome.php index e0c26555..75c4f11e 100644 --- a/application/third_party/recommend/views/welcome.php +++ b/application/third_party/recommend/views/welcome.php @@ -5,14 +5,39 @@

广告管理 添加广告

- +