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 8235087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:41:11+00:00 2026-06-07T18:41:11+00:00

I am trying a Keyword search. I am looking in the fields ARTWORK_title and

  • 0

I am trying a “Keyword” search. I am looking in the fields ARTWORK_title and ARTWORK_keywords. The ARTWORK_keywords field is where the user can enter multiple tags to search on.

I have built a query up and feel this is the right way, But I am just not getting ARTWORK_title passed back through in the DB Query.

My PHP Function is as follows….

$my_keywords = explode(",", $search_string);

    $searchfields = array('ARTWORK_title', 'ARTWORK_keywords');

    $this->db->select('*');
    $this->db->from('artwork');
    $this->db->where('ARTWORK_status', '1');

    //$where_string = '(';

    foreach($my_keywords as $keyword)
    {
        foreach($searchfields as $field)
        {
            $where_string = $field . ' LIKE \'%' . $keyword . '%\' ';
        }


        //$where_string .= substr($where_string, 4) . ')';

        $this->db->where($where_string);
}

However when profiling the SQL Query I am getting the following MySQL Query back….

SELECT *
FROM (artwork)
WHERE ARTWORK_status = ‘1’
AND ARTWORK_keywords LIKE ‘%Blue%’
AND ARTWORK_keywords LIKE ‘%Orange%’

It is just not getting the ARTWORK_title field in the query at all.

Any ideas where I am going wrong?

Many Thanks in advance.

  • 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-07T18:41:13+00:00Added an answer on June 7, 2026 at 6:41 pm

    You are erasing the $where_string value with each iteration.

    Modify it like this:

    $where_string = '';    
    $counter = 0;
    foreach($my_keywords as $keyword)
    {
        foreach($searchfields as $field)
        {
            if ($counter > 0) {
               $where_string .= ' AND ';    
            }
            $where_string .= $field . ' LIKE \'%' . $keyword . '%\' ';
            $counter++;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a keyword message style method, but I can't figure
Im trying to implement the search feature in my website. when the search keyword
I am trying to create a JavaScript regular expression that can find a keyword
I am trying to get the search keyword from a referrer url. Currently, I
I'm trying to search Google but the keyword 'go' makes it difficult to find
I am trying to make my keyword search as efficient as possible using the
I was trying to query a database table by search keyword. My SQL is
I'm trying to make it quick and easy to perform a keyword search on
I'm trying to create the search form with keyword highlighting, but obviously I won't
I am trying to create a simplified search box that will match multiple columns

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.