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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:10:18+00:00 2026-06-11T04:10:18+00:00

The way this is set up, it will pull up results for multiple words

  • 0

The way this is set up, it will pull up results for multiple words in the $term variable.
I want it to pull up results that only match all words inside the $term span between main, secondary, sub columns.

Right now if $term is: “Hello World” it will pull results from the database:

id  | main               | secondary      | sub

01  | statements         | hello world    | blah
02  | hello              | what's up?     | anything here
03  | life rocks         | worldwide web  | anything else here
04  | where in the world | she said hello | bleh

When what I would like is only results 01 and 04 to pull up because they include the full $term of Hello And World

Here’s my code. I’ve tried searching on here, and in Google. But in truth I don’t know what to look for. All I’ve found are full text searching documents, which I’m already doing here. I haven’t found any to say how to pull the exact result. (The sprintf is there because I guess I need that to be able to return it in a JSON response?

$query = sprintf("SELECT id, main, secondary, sub, 
    MATCH(main, secondary, sub) AGAINST('". $term ."' IN BOOLEAN MODE) AS score 
    FROM list_genres 
    WHERE MATCH (main, secondary, sub) AGAINST('". $term ."' IN BOOLEAN MODE)
    ORDER BY score DESC LIMIT 15");
  • 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-11T04:10:20+00:00Added an answer on June 11, 2026 at 4:10 am

    Your sentece is wrong, first sprintf() should receive as parameters, the terms, and use %s wherever you want to add it to the sql, also for multiple words you need to add a + for each word.

    The code should be something like this:

    $term = '+' . str_replace(' ',' +',$term); // Remove this line if you don't want search multiple terms
    $query = sprintf("SELECT id,main,secondary,sub, MATCH(main, secondary, sub) AGAINST('&s' IN BOOLEAN MODE) as score 
        FROM list_genres WHERE MATCH (main, secondary, sub) AGAINST('%s' IN BOOLEAN MODE) 
        ORDER BY score DESC LIMIT 15", $term, $term); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
I am building a web application that will pull event logs from multiple servers
I have a menu set up this way: <div id='top-navigation'> <ul> <li><a class='top-nav-button-unclicked' href='#'>SUBJECT</a></li>
I have set the form decorators in this way: <?php $this->setElementDecorators(array( 'Label', array(array('labelTd' =>
I am working on smartphone site. Is there a way to set Bookmark this
Are there any way to access or set iphone's alarm? Im assuming if this
Hope this makes sense... Is there a simple way to return a set of
I'm trying to solve this problem in a pure-functional way, without using set! .
There is this way, of course: OuterClass.this . But that's very clumsy. Ideally, there'd
I am currently developing a dynamic RSS feed that will automatically pull articles from

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.