0

私は自分のアプリケーションで Codeigniter 検索ボックスを開発しましたが、入力された「APLE」などのスペル候補を実装する方法は、「APPLE」を意味していましたか?

誰でも、この機能を整理するのを手伝ってください。

コントローラ ロジック:

function deals_search() {

        $search_string = $this->input->post('search_keyword');
        $query = $this->consumer_model->get_serching_deals($search_string);
        $data['searched_deals_count'] = count($query);
        if ($query) {

            foreach ($query as $row) {
                $row->id = urlencode($this->encrypt->encode($row->deal_id, 'deal_id'));
                $serched_deals[] = $row;
            }

        $data['searched_deals'] = $serched_deals;
    } else {
        $data['no_deals_msg'] = "did not match the key word";
    }
    $data['search_string'] = $search_string;
    $data['category'] = $this->consumer_model->category_menu();
    $this->load->view('side_menu', $data);    //1)side  menu
    $this->load->view('common/consumer_menu'); //2)consumer main menu
    $this->load->view('search_deals', $data);
}

クエリ/モデル ロジック:

public function get_serching_deals($search_string)
{
$query = $this->db->query("SELECT *
FROM deal ds, merchant m, deal_cat dc, category c, reservation_dates rd, deal_reservation dr
WHERE (
deal_title LIKE '%$search_string%'
OR deal_title LIKE '%$search_string%'
OR actual_value LIKE '%$search_string%'
OR deal_price LIKE '%$search_string%'
OR deal_location LIKE '%$search_string%'
OR deal_brief_desc LIKE '%$search_string%'
OR deal_fine_print LIKE '%$search_string%'
OR  m.mrt_name LIKE '%$search_string%'
OR  m.address1 LIKE '%$search_string%'
OR  m.address2 LIKE '%$search_string%'
OR  m.city LIKE '%$search_string%'
OR  m.state LIKE '%$search_string%'
OR  m.zipcode LIKE '%$search_string%'
OR  m.telephone1 LIKE '%$search_string%'
OR  m.telephone2 LIKE '%$search_string%'
OR  m.telephone2 LIKE '%$search_string%'
OR  m.description LIKE '%$search_string%'
OR  c.ctg_name LIKE '%$search_string%'
)
AND ds.mrt_id = m.mrt_id
AND ds.dls_id =2
AND dc.deal_id = ds.deal_id
AND c.ctg_id = dc.deal_ctg_id
AND rd.reserve_id = dr.reserve_id
AND dr.deal_id = ds.deal_id
AND rd.date = '2013-08-29'")->result();
        return $query;
    }

ビュー/プレゼンテーション ロジック:

            <?php
            foreach ($searched_deals as $deal_data) {
                ?> 
     <div class="imgborder_reg">
            <div class="image-box_reg">
                <div class="discountLabel"><div class="discountText"><?= $deal_data->discount ?>% Off</div> </div>
                <div class="image-container_reg">
                    <img src="<?php echo base_url(); ?>/uploads/deal_images/<?= $deal_data->deal_image ?>" alt="Food">
4

0 に答える 0