javascript - I want to create advanced search using ajax codeigniter per categories

723

I am making a search function with codeigniter. The search needs to show the search result per category, when I click the categories it will be show the real result (detail, with the image). For the search I made a form:

Title:
Author:
Publisher:
Year Published
ISBN : 

<btn submit>

if I submit it will show the URL like this:

http:readynew1.8/advancedsearch/search?advTitle=diktat&advAuthor=&advPublisher=&advYear=&advISBN=
===========================================
Search Result
==========================================
Book 6
Journal 4

The code is fine until here.

The problem is that when I click the category book I cant get the data that was sent from the input form. If I use$this->input->get(); and send it as parameter to my functionshowdetails(Title,ISBN); the parameter cant be null, and also I cant find any book with title that contains a comma, so I think I need to get the input data with ajax with form.serialize but I still don't get the data from input text.

Can anyone help me?

code search controller that I get for categories

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);

}

my function to get details:

function test($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);*/
}

}

please help me if you have another idea..

People are also looking for solutions to the problem: javascript - Dynamic dropdown select option first option from the service and the second option will select the doctor of the services selected.

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.