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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:01:29+00:00 2026-06-12T00:01:29+00:00

I have a large database containing part numbers for a filter company. Several of

  • 0

I have a large database containing part numbers for a filter company. Several of the products have similar years and model numbers. I have a php script that is searching a text keyword section for each part.

So for a 1997-1999 Honda Crf 250 090987 19.95 the keywords are:
1997 1998 1999 honda crf 250 090987

I got the code from a tutorial and it’s written to search the keywords section for everything separated by a space. The problem is that a lot of the listings have honda or similar year spreads.

I need to figure out how to alter the php to narrow the results so if someone types “1997 honda”, all of the hondas and ’97s don’t show up but only ones that are 1997 hondas.

I’m new to php and I’ve looked all around and can’t figure it out. Any help will be thoroughly appreciated.

here’s the php:

$keywords = $_GET['keywords'];
$terms = explode(" ", $keywords);
$query = "SELECT * FROM search WHERE ";

foreach ($terms as $each){
    $i++;
    if ($i == 1)
        $query .= "keywords LIKE '%$each%' ";
else
    $query .= "OR keywords LIKE '%$each%' ";

}


// connect
mysql_connect("localhost", "root", "root");
mysql_select_db("catalog");

$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0){

    while ($row = mysql_fetch_assoc($query)){
        $id = $row['id'];
        $year = $row['year'];
        $manufacturer = $row['manufacturer'];
        $product = $row['product'];
        $partnumber = $row['partnumber'];
        $price = $row['price'];

        echo "<div id=\"results\">
        <div class=\"words\">$year</div><div class=\"words\">$manufacturer</div><div class=\"words\">$product</div><div class=\"words\">$partnumber</div>$price<br /></div>";
    }
}
else
    echo "<div class=\"no_results\"><center>No results found for \"<b>$keywords</b>\"</center></div>";


// disconnect
mysql_close();

?>

  • 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-12T00:01:29+00:00Added an answer on June 12, 2026 at 12:01 am

    Interesting problem.

    I thought of 2 approaches:

    (1) if you have control over the database structure, you could SELECT WHERE (make = ‘Honda’ AND Year IN (1997,1998,1999)) AND the “like” stuff you already have (without the make/year). But you would need to separate out the model years and make into separate fields.

    (2) otherwise, if we can assume the input is always “year(s) make [other keywords], we could do what izuriel suggested while I was typing this, just “AND ‘keywords = ‘1997’ AND keywords = ‘honda’ AND (our existing list of “like” clauses)”.

    that way you’d get only 1997 Hondas that have any or all of the other keywords.

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

Sidebar

Related Questions

We have a large database containing a lot of stored procedures. Now we are
I have a large database containing words and their inflected forms , e.g.: BASIC_FORM
I'm testing a php script to create csv file which containing large amount of
I have large numbers of tables in my database. I am searching for a
I have a large file from 2007 containing a backup (as a SQL Script)
I have a php script that steps through a folder containing tab delimited files,
I have a large database containing more than five million records, this database has
I have a MYSQL database containing the names of a large collection of people.
I have a fairly large database containing a number of different tables representing different
I have data database containing some rather large strings, each of which holds a

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.