1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.
  2. Better Analytics for WordPress Get It Free

return mysql database results dependent on town entered

Discussion in 'PHP' started by ianhaney, Dec 28, 2012.

  1. #1
    Hi


    I am bit stuck, I want to return results from a mysql database when a user enters their town or postcode in for example below


    they enter in their town or post code and a list of area managers is displayed closest to their town or postcode along with their contact number


    Is that possible


    Thank you


    Ian
     
    ianhaney, Dec 28, 2012 IP
  2. geforce

    geforce Active Member

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    It would depend your your database table is structured and what data you have. You would need to do a check on how close each location is to the user after returning all the results.
     
    geforce, Dec 30, 2012 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,883
    Likes Received:
    34
    Best Answers:
    51
    Trophy Points:
    100
    #3
    If by "close" you mean geographically, you'll need the latitude and longitude of each manager in the database, since you'll need them to calculate "closeness". You'll also need a database of postcodes vs. lat/long to determine what the user's lat/long is. (You might be able to use Google for that, depending on the country you're located in.)
     
    Rukbat, Dec 30, 2012 IP
  4. aman@odigma.com

    aman@odigma.com Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    depends on your structure of tables... either you can store every place's name with near by place using latitude ... or you can also use google map for this purpose.
     
    aman@odigma.com, Jan 1, 2013 IP
  5. bigmarvelfan

    bigmarvelfan Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can also filter things by area code, zip code and city.
     
    bigmarvelfan, Jan 2, 2013 IP
  6. BarbaraMibram

    BarbaraMibram Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Tell me how can i filter these atributes...???
     
    BarbaraMibram, Jan 2, 2013 IP
  7. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,883
    Likes Received:
    34
    Best Answers:
    51
    Trophy Points:
    100
    #7
    With a WHERE clause in your SQL query.

    WHERE zipcode = '12345'

    or

    WHERE areacode = '305'

    etc.
     
    Rukbat, Jan 2, 2013 IP
  8. MS.USD

    MS.USD Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    <?php

    $ip = $_SERVER['REMOTE_ADDR'];
    $api_key = "fa21adbc3ead7eda75b0192aa6b296e7ddba9a6e71c32018ae1938289241af58";
    $data = file_get_contents("http://api.ipinfodb.com/v3/ip-city/?key='".$api_key."'&ip=74.125.45.100&format=json");
    $country_code = json_decode($data);
    $code = $country_code->{'countryCode'};

    echo '<img src="'.$code.'.jpg"/>';
    ?>
     
    MS.USD, Jan 3, 2013 IP