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.
Originally asked by: Homer_J on Stack Overflow


Answers