View Full Version : Select Multiple choices from fields

08-25-2007, 07:59 AM
I have a form designed that will search and display meetings, based on the day, city and program. I would like to be able to select the same meetings, but allow you to pick multiple days or multiple cities.

The day is selected from a drop down list on the form, while the cities is pulled from the database. I tried to set the two settings to allow multiple selections , but it didn't appear to work.

Here is a sample of what i have in the form now....

City / Town: <select name='City'>


$result = mysql_query("SELECT * FROM City") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo "<option>$row[City]</option>";

Day of Week:<select name="Day">
<option value="No Selection Made">Select Day</option>
<option value="Sunday">Sunday</option>
<option value="Monday">Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>

This is the code I am using to get the info from the DB and it is working.

$result = mysql_query("SELECT * from Meetings WHERE Program='".$_POST['Program']."' and City='".$_POST['City']."'
and Day='".$_POST['Day']."' ORDER BY Time")
or die(mysql_error());

Another question... Is it possible to sort the results by several fields. I have it sorting by the time the meeting starts, but if I can make it display multiple days, I would like it to sort by day, then by time.... hope this makes sense.



08-25-2007, 08:20 PM
yes you can sort by multiple fields in the order by clause. if you can query your records and get the output directly in mysql then your question really concerns your php code. as a result it might be best to move the thread to the php forum so you can get your help quicker.

i can move the thread if you'd like to.

08-25-2007, 08:35 PM
Please move it for me. In the order by clause, which I am using, do I just repeat the order command, for each field I want sorted?

08-25-2007, 11:23 PM
fieldA asc, fieldB desc, fieldG

for example

the asc is default ascending order you can leave it in or out as above.