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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:38:07+00:00 2026-05-16T14:38:07+00:00

EDIT: The drop down menus have the following listed in them: Typing Course Daily

  • 0

EDIT:

The drop down menus have the following listed in them:

Typing Course
Daily Marketing Course

When using the code below to add selected text form the dropdown into the MySQL statement, only the first word appears ie. ‘Typing’ and ‘Daily’, the code looks like this:

SELECT * FROM `acme` WHERE `course` IN('Typing', 'Daily')AND `date` IN('2010-08-27', '2010-08-31')

it should be this:

SELECT * FROM `acme` WHERE `course` IN('Typing Course', 'Daily Marketing Course')AND `date` IN('2010-08-27', '2010-08-31')

Original question below:

Hi all,

Ok, I’ll do my best to explain what I would like to do.

I have two dropdown menus set to multiple, the first is Course and the second is Date, here is the code that populates each dropdown:

Course

echo "<select name='course' value='' multiple='multiple'>";
            // printing the list box select command
            echo "<option value=''>All</option>";
            while($ntc=mysqli_fetch_array($queryc)){//Array or records stored in $nt
            echo "<option value=$ntc[course]>$ntc[course]</option>";
            /* Option values are added by looping through the array */
            }
            echo "</select>";// Closing of list box 

Date

echo "<select name='date' value='' multiple='multiple'>";
        // printing the list box select command
        echo "<option value=''>All</option>";
        while($nt=mysqli_fetch_array($queryr)){//Array or records stored in $nt
        echo "<option value=$nt[dates]>$nt[dates]</option>";
        /* Option values are added by looping through the array */
        }
        echo "</select>";// Closing of list box 

The main problem I have is passing the results of each dropdown to a MySQL query. For example, if a user select from the Course dropdown ‘Typing’ AND ‘Marketing’ – I need the MySQL query to be:

SELECT * FROM acme WHERE course = 'Typing' OR course = 'Marketing'

In addition, I also need to add the second dropdown into the equation, so working on the assumption the user has selected ‘Typing’ AND ‘Marketing’, they then select 21-06-2010 from the Date dropdown, so the query then needs to be:

SELECT * FROM acme WHERE course = 'Typing' OR course = 'Marketing' AND date = '21-06-2010' OR date = '18-05-2010'

Clearly, I also need to build in if they select more than one date form the dropdown.

I hope I have explained clearly enough what I’m looking to achieve..any and all help gratefully received. Really struggling to get my head around this one.

Thanks in advance,

Homer.

  • 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-16T14:38:07+00:00Added an answer on May 16, 2026 at 2:38 pm

    Use WHERE value IN ('a', 'b'):

    SELECT * FROM acme WHERE course IN ('Typing','Marketing') AND date IN ('21-06-2010', '17-09-2010');
    

    In HTML (or the PHP that outputs HTML), add [] to fieldnames:

    <select name='course[]' value='' multiple='multiple'>
    

    in PHP:

    $courses=$_POST['course'];
    $courses=array_map('mysql_real_escape_string', $courses);
    
    
    $dates=$_POST['date'];
    $dates=array_map('mysql_real_escape_string', $dates);
    
    $query = 'SELECT * FROM `acme` WHERE ';
    $query.='`course` IN(\''. join("', '", $courses). '\')';
    $query.='AND `date` IN(\''. join("', '", $dates). '\')';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With the following jQuery code I have created a drop down that updates the
Using the example at the following URL: http://www.kavoir.com/2009/02/php-drop-down-list.html How can I have that drop
I have the following CSS/HTML setup http://jsfiddle.net/UDAUY/ How do I align the drop down
I have a drop down menu which has the following html structure: <ul class=menu>
EDIT: See my answer below--> I am wanting to have a view that when
I have large list of the drop-down menu. Some of the option have very
i have been trying to have a drop down menu opon mouseover of the
I am using a drop down menu for a website and in IE8 it
I have the following code that loads element from a remote page (under same
I have the following code that loads element from a remote page (under same

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.