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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:47:05+00:00 2026-05-25T00:47:05+00:00

I am making a search function on a website to let users search values

  • 0

I am making a search function on a website to let users search values held in a mysql database.

As an example:

There are two products in this table.

One has a description value of “coke can 330ml” and the other “sprite can 330ml”.

Now when searching for these items, say a user enters can as their string. Both items are displayed because they both contain can.

If the user enters coke, the coke can will be returned.

Now imagine that you had every can of soda ever made inside the database, each as a product.

Search functionality like this, would be a bit troublesome. say a user wanted only two products, these being the coke and sprite cans.

They would need to search something like “coke OR sprite AND can AND 330ml”

This should only return the two products used in my example.

Not the problem that i face is this. My search feature runs like my original example. I am trying to include some kind of and, or, not functionality, and have not quite decided how this should all work out.

Currently, a seach of “coke can” will return only the results containing coke and can. But if I searched “coke sprite can” No results will be returned as there are no results that contain all 3 of the words used in the string.

Here is the query:

$dataQuery = "
         SELECT *
         FROM `products`
         WHERE upper(`desc`)
         LIKE '%"
             . implode("%'
         AND upper(`desc`)
         LIKE '%",
             $keywords_array) 
             . "%'
         ORDER BY `desc`";

$keywords_array is an array built up from the user entered search string, after validation, the code for this is as follows:

$find = strtoupper($find); 
$find = strip_tags($find); 
$find = trim ($find);
$_SESSION['find'] = $find;
$keywords_array = explode(' ', $find);

$find is the string set by the post value of the search string entered by the user.

Does anyone have any ideas on a good way to accomplish what I have explained?

If you need any additional code, or a better explanation, please just ask!

Thanks!!

  • 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-05-25T00:47:05+00:00Added an answer on May 25, 2026 at 12:47 am

    You are looking for mysql fulltext search with the limitation that it has a default minimum word length of 4 characters, so you can’t search for “can” if you can’t edit the server configuration.

    Also, it has a “stop word” policy that doesn’t deliver results on words that appear in more than 50% of the overall data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a search function for my website, which finds relevant results from a
Ok, I attempted at making my own search function which doesnt work very well.
Im making my own function to search for the total number of something. but
I have set up a website (www.autobodypartsnow.com) and the search function has gone haywire.
So I'm making a search function for comments. Someone else here helped me with
I'm making my search function but I don't know how to select only rows
I am using SQL Server 2000 and ASP.Net with c# for making a search
I'm making a simple search form in rails. In my search view I have
I am making a form to search for colleges based on athletic programs offered
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created

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.