Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select Multiple choices from fields

    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....
    Code:
    City / Town: <select name='City'>
    
                            <?php
    
        $result = mysql_query("SELECT * FROM City") or die(mysql_error());
    while ($row = mysql_fetch_assoc($result)) {
    echo "<option>$row[City]</option>";
    }
    
        ?></select>
                                            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>
                            </select>
                            </center><BR><BR><BR>
    This is the code I am using to get the info from the DB and it is working.
    Code:
    $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.

    Thanks,

    Ken
    Last edited by kenwvs; 08-25-2007 at 08:05 AM. Reason: wrong title

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    168
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Code:
    ORDER BY
    fieldA asc, fieldB desc, fieldG
    for example

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •