Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7988461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:27:36+00:00 2026-06-04T12:27:36+00:00

$all = $this->input->get(‘all’); if($all) { $keywords = $this->input->get(‘search’); $data[‘search’] = $keywords; $this->session->set_flashdata(‘search’, $keywords); $query

  • 0
    $all = $this->input->get('all');

    if($all)
    {
        $keywords = $this->input->get('search');
        $data['search'] = $keywords;
        $this->session->set_flashdata('search', $keywords);
        $query = "SELECT *  FROM `investOffers`, `news`";
        $counts = "SELECT count(*) as count FROM  `investOffers`, `news`";
        $first = false;
        if($keywords)
        {
            $data['keywords'] = $keywords;
            $this->session->set_flashdata('keywords', $keywords);
            $keywords = explode(" ", $keywords);
            foreach($keywords as $k)
            {
                if(!$first)
                {
                    $query .= " WHERE investOffers.desc LIKE '% ".$k." %' OR investOffers.title LIKE '% ".$k." %'";
                    $query .= " OR news.desc LIKE '% ".$k." %' OR news.title LIKE '% ".$k." %'";
                    $counts .= " WHERE investOffers.desc LIKE '% ".$k." %' OR investOffers.title LIKE '% ".$k." %'";
                    $counts .= " OR news.desc LIKE '% ".$k." %' OR news.title LIKE '% ".$k." %'";
                    $first = true;

                }
                else
                {
                    $query .= " OR investOffers.desc LIKE '% ".$k." %' OR investOffers.title LIKE '% ".$k." %'";
                    $query .= " OR news.desc LIKE '% ".$k." %' OR news.title LIKE '% ".$k." %'";
                    $counts .= " OR investOffers.desc LIKE '% ".$k." %' OR investOffers.title LIKE '% ".$k." %'";
                    $counts .= " OR news.desc LIKE '% ".$k." %' OR news.title LIKE '% ".$k." %'";
                }
            }


        }
            $page = $this->uri->segment(2);
            if($page)
            {
                $query .= " ORDER BY investOffers.date DESC LIMIT ".$page.", 10";
                $counts .= " ORDER BY investOffers.date DESC LIMIT 10";
            }
            else
            {
                $query .= " ORDER BY investOffers.date DESC LIMIT 10";
                $counts .= " ORDER BY investOffers.date DESC LIMIT 10";
            }
        $data['query'] = $this->db->query($query);
        $counts = $this->db->query($counts);
        foreach($counts->result() as $q)
        {

        $count = $q->count;
        break;

        }
        $config['base_url'] = base_url().'/search';
        $config['prev_link'] = false;
        $config['next_link'] = false;
        $config['last_link'] = false;
        $config['first_link'] = false;
        $config['suffix'] = '?'.http_build_query($_GET, '', "&");
        $config['cur_tag_open'] = '<strong><img src="'.IMAGE.'pagerArrow.png" class="pagerArrow" />';
        $config['cur_tag_close'] = '</strong>';
        $from = intval($this->uri->segment(2));
        $config['per_page'] =  10;   
        $config['num_links'] = 5;    
        $config['uri_segment'] = 2;  
        $config['total_rows'] = $count; 
        $this->pagination->initialize($config);
        $data['pager'] = $this->pagination->create_links();
        $data['content'] = $this->load->view(SITE.'search', $data, true);
        $this->load->view(SITE.'layout', $data);
        return true;

    }

so this is a search query, first we check if a search is “all”, it means search by all the site, so then i make a array of keywords separated by whitespaces, entered in the form, so then i put it in a flash session for preg_match in the view, this is for preg_match highlighting text in the view of generated results, so then i make a concatenation of the query be adding more LIKE , so the problem is when i input 1 keyword, it gives me different results and its okey, but when i enter 2 or many keywords, it gives me the same results, i mean a list of result that are exact the same, i can’t understand why is that, in the view its all okay, the problem is in this place of code, i have tried to set th DISTINCT keyword in the query, but it does not helped…

ps: this is codeigniter, MVC, this is a controller, i don’t use models, because i don’t want to open many files 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:27:37+00:00Added an answer on June 4, 2026 at 12:27 pm

    Check if your

    $keywords = explode(" ", $keywords);
    

    is returning a length greater then 1. Since you are getting $keywords from a GET, it is possible that you need to urldecode your variable before passing it in the explode function.

    $keywords = urldecode($keywords);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
Hallo all. I got this piece of code: <div> <input id=id1 name=radioButton type=radio> <input
im trying to get the parent of this input but it just wont, i
EDIT: after reading all the input from the other users, i decided, to use
I have a select input on my page. this select input displays/hides fields in
I want to get all GET and POST parameters from Web Page. Let's say
I have <input type=file id=basicUploadFile multiple=multiple> and I want to get all file names
hello all this seems to be my problem I have a table in mysql
first of all: this is not the same as this . The ModelBackend has
first of all this is my third question about web services here and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.