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

  • Home
  • SEARCH
  • 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 9018699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:35:45+00:00 2026-06-16T04:35:45+00:00

I have a PHP code that runs a MySQL query to sort some output

  • 0

I have a PHP code that runs a MySQL query to sort some output data by a filter selected.

The problem that I have is when I filter by more than 1 word, i.e. when I filter by color it works fine for RED, YELLOW, etc.. but not for BLUE NAVY.

I thought it would be enough by adding '" but it is not.

Here is my current code:

 <?php
$colors = $con -> prepare("SELECT DISTINCT color_base1 FROM item_descr ORDER BY color_base1 ASC");
$colors ->execute();
while ($colorBoxes = $colors->fetch(PDO::FETCH_ASSOC))
{
echo "<input type='checkbox' class='regularCheckbox' name='color' value='".$colorBoxes[color_base1]."' /><font class='similarItemsText'>   ".$colorBoxes[color_base1]."</font><br />";
}
?>

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-06-16T04:35:46+00:00Added an answer on June 16, 2026 at 4:35 am

    You need quotes around your array indexes.

    Change: $colorBoxes[color_base1]

    To: $colorBoxes['color_base1']

    Bonus points:

    printf(
        "<input type='checkbox' class='regularCheckbox' name='color' value='%s' /><font class='similarItemsText'>   %s</font><br />",
        $colorBoxes['color_base1'],
        $colorBoxes['color_base1']
    );
    

    Also, your form data is probably going to submit pretty weird when the input name field has a space in it. Try a var_dump($_REQUEST) after the form is submitted to see what the deal is, but I would suggest not using spaces in your color_base1 field.

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

Sidebar

Related Questions

I have code that runs a query on the database and returns some data
I have some PHP code that generates dynamic tables of data on the fly.
I have the following PHP code which runs a MySQL query and returns the
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have some PHP code that is designed to make a spreadsheet with formulas
I have some PHP code that generates a calendar and then outputs html to
So I have some PHP code that looks like: $message = 'Here is the
I have the following php code that gets a serialized array from a mysql
<a href=tags.php onclick=return popitup('tags.php')>tags</a> I have this line of code that runs the javascript
I have the following MySQL query that I execute from a .php page SELECT

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.