Results 1 to 1 of 1

Thread: Search Ads by City dropdown

  1. #1
    Thread Starter
    serno's Avatar
    Join Date
    Apr 2013
    Location
    Denmark
    Posts
    31
    Thanks
    22
    Thanked 1 Time in 1 Post

    Search Ads by City dropdown

    Hi,

    I managed to get a dropdown of cities out of this code. The idea is when selected the user is taken to the page where ads are according to the selected city.
    PHP Code:
    <form action="<?php bloginfo('url'); ?>" method="get">
    <select name="cp_city" id="cp_city" onchange='return this.form.submit()'>
        <?php

            
    // get all the custom field labels so we can match the field_name up against the post_meta keys
            
    $sql "SELECT field_values FROM $wpdb->cp_ad_fields f WHERE f.field_name = 'cp_city'";
            
    $results $wpdb->get_row$sql );
            if ( 
    $results ) {
                    
    $options explode','$results->field_values );
                echo 
    '<option selected="selected">Select a City</option>';
                    foreach ( 
    $options as $option ) {
                echo 
    '<option value="'.$option.'">'.$option.'</option>';
                    }
            }
        
    ?>
    </select>
    </form>
    Thanks for helping

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Advanced Search City and Zip as Dropdown not text field.
    By frcamp in forum ClassiPress General Discussion
    Replies: 7
    Last Post: November 6th, 2013, 11:16 AM
  2. Samcy Editing or adding city dropdown
    By manishkhullar in forum Help Using ClassiPress
    Replies: 4
    Last Post: August 30th, 2013, 07:43 AM
  3. vantage near city, country dropdown
    By linkpoin2 in forum Vantage General Discussion (Legacy)
    Replies: 1
    Last Post: June 7th, 2013, 07:52 PM
  4. Where to put this mod that adds a dropdown Search by City. Easy! Or should be...
    By thomson1833 in forum ClassiPress General Discussion
    Replies: 2
    Last Post: July 23rd, 2012, 08:28 PM