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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:47:15+00:00 2026-06-09T16:47:15+00:00

I have a MySQL table and one of the fields is category, the values

  • 0

I have a MySQL table and one of the fields is “category,” the values of which include articles, studies, quotes, etc. For the search form I have checkboxes that correspond with these categories for the user to select which, if not all, to search from.

Right now the following snippet works for searching the entire table indiscriminately (i.e., from rows with “category” including articles, studies, quotes, etc. However, how would I change the following so that if a person selects only “Articles,” the query will return only the rows that have the field “category” with the corresponding value?

$category = $_GET["category"];
$query = "User-submitted query";
$search = mysql_query("SELECT title,body,
MATCH(title, body) 
AGAINST('$query' IN BOOLEAN MODE)
AS score FROM resources
WHERE MATCH(title, body) AGAINST ('$query' IN BOOLEAN MODE)");

I tried adding in WHERE category = '$category' ($category in this case would be “Articles”) above but it did not work.

BTW: I am aware of the mysql/mysqli and security user-input issues.

  • 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-09T16:47:16+00:00Added an answer on June 9, 2026 at 4:47 pm

    I figured out the problem. The following works:

    $category = $_GET["category"];
    $query = "User-submitted query";
    $search = mysql_query("SELECT title,body,
    MATCH(title, body) 
    AGAINST('$query' IN BOOLEAN MODE)
    AS score FROM resources
    WHERE MATCH(title, body) AGAINST ('$query' IN BOOLEAN MODE)
    AND category = '$category'");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a large mysql database table in which one column contains values ranging
I have a MySQL table in which one of the fields is variation and
I have a classified_id variable which matches one document in a MySql table. I
I have a mysql table and one of the fields is 'template'. This field
I have one mysql table called 'games' with the fields: id, team1, team2, and
I have mysql table called it as R which contains many fields, but I
I have 2 fields in one mysql table. One field has full sentence and
If I have a MySQL-table consisting of the fields one , two , three
I have two table fields in a MySQL table. One is VARCHAR and is
I have a MySQL table (table1) with following fields... id, title, description, detail, category,

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.