我正在使用codeigniter创建搜索功能。 搜索需要显示每个类别的搜索结果,当我点击类别时,它将显示实际结果(详细信息,带图像)。 为了搜索我做了一个表格:
Title:
Author:
Publisher:
Year Published
ISBN :
<btn submit>
如果我提交,它将显示如下网址:
http:readynew1.8/advancedsearch/search?advTitle=diktat&advAuthor=&advPublisher=&advYear=&advISBN=
===========================================
Search Result
==========================================
Book 6
Journal 4
这里的代码很好。
问题是,当我点击类别书时,我无法获得从输入表单发送的数据。
如果我使用$this->input->get();
并将其作为参数发送到我的函数showdetails(Title,ISBN);
参数不能为null,而且我也找不到任何包含逗号的书籍,
所以我认为我需要使用带有form.serialize的ajax获取输入数据,但我仍然无法从输入文本中获取数据。
任何人都可以帮助我吗?
我为类别搜索的代码搜索控制器
public function search()
{
$AssetTitle = $this->input->POST("advTitle");
$Author = $this->input->POST('advAuthor');
$Publisher = $this->input->POST('advPublisher');
$Year = $this->input->POST('advYear');
$ISBN = $this->input->POST('advISBN');
$result = $this->advanced_model->search_result();
$data['temp']=$this->advanced_model->getcountadvanced();
$data["CatId"]=$this->viewbook_model->getCategory();
$x=0;
if(count($result) > 0){
foreach($result AS $d)
{
$data['searchresult'][$x] = array(
'CategoryAssetName' => $d['CategoryAssetName'],
'CategoryAssetId' => $d['CategoryAssetId'],
'AssetTitle' => $d['Bibli'],
'Author' => $d['Bibli'],
'Publisher' => $d['PublisherId'],
'Year' => $Year,
'ISBN' => $ISBN
);
$x++;
}
}
else
{
$data['searchresult'] = array();
}
$page_content["page_title"] = "Advanced Search";
$page_content["title"] = "Advanced Search";
$page_content["icon_title"] = "search";
$menu_params["current_navigable"] = "AdvancedSearch";
$menu_params["sub_current_navigable"] = "";
$page_content["menu"] = $this->load->view("main_menu", $menu_params, true);
$page_content["content"] = $this->load->view("advancedsearch", $data, true);
$page_content["navmenu"] = $this->load->view("nav_menu",$data, true);
$this->load->view("template/main_template", $page_content);
}
我获取详细信息的功能:
功能测试($ CategoryAssetId =“”,$ AssetTitle =“”,$ Author =“”,$ Publisher =“”,$ Year =“”,$ ISBN =“”){
$data = $this->input->post();
echo $data;
$data["CatId"]=$this->viewbook_model->getCategory();
/*$AssetTitle = $this->input->GET('advTitle');
$Author = $this->input->GET('advAuthor');
$Publisher = $this->input->GET('advPublisher');
$Year = $this->input->GET('advYear');
$ISBN = $this->input->GET('advISBN');
*/
/*echo $AssetTitle.'<br />';
echo $Author.'<br />';
echo $Publisher.'<br />';
echo $Year.'<br />';
echo $ISBN.'<br />';*/
$AssetTitleEx = explode("-",$AssetTitle);
$AssetTitleIm = implode(" ",$AssetTitleEx);
//echo $Author;
$AuthorEx = explode("-",$Author);
$AuthorIm = implode(" ",$AuthorEx);
//echo $AuthorIm;
$PublisherEx = explode("-",$Publisher);
$PublisherIm = implode(" ",$PublisherEx);
$result = $this->advanced_model->searchresult($CategoryAssetId,$AssetTitleIm,$AuthorIm,$PublisherIm,$Year,$ISBN);
//print_r($result);
//echo count($result);
$x=0;
if(count($result) > 0){
foreach($result AS $d)
{
$data['tem'][$x] = array(
'categoryassetid' =>$d["CategoryAssetId"],
'AssetTitle' => $d["AssetTitle"],
'AssetSubtitle' => $d["AssetSubtitle"],
'PublisherName' => $d['PublisherName'],
'PublishYear' => $d['PublishYear'],
'MainAuthor' => $d['MainAuthor'],
'ISBN' => $d['ISBN'],
'Photo' => $d['Photo'],
'Bibli' => $d['Bibli'],
'CategoryAssetName' => $d['CategoryAssetName'],
'Description' => $d['Description']
);
$x++;
}
}
else
{
$data['tem'] = array();
}
/*$page_content["page_title"] = "Advanced Search";
$page_content["title"] = "Advanced Search";
$page_content["icon_title"] = "search";
$menu_params["current_navigable"] = "AdvancedSearch";
$menu_params["sub_current_navigable"] = "";
$page_content["menu"] = $this->load->view("main_menu", $menu_params, true);
$page_content["content"] = $this->load->view("advancedsearch", $data, true);
$page_content["navmenu"] = $this->load->view("nav_menu",$data, true);
$this->load->view("template/main_template", $page_content);*/
}
}
如果你有其他想法,请帮助我。