#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0

    PHP MySql Query help


    Hi professionals.

    i am new to php and mysql and I am trying to query my database to calculate the distance with the help from google instructions on this page.

    https :// developers.google.com/maps/articles/phpsqlsearch_v3

    when I try to query my database with the following query as advised by them no results are returned. here is my query, I think it is because of the order of exectuion of sql statement and it does not recognise the "distance" column name

    SELECT suburb, state, latitude, longtitude, ( 6371 * acos( cos( radians(153) ) * cos( radians( latitude ) ) * cos( radians( longtitude ) - radians(-27) ) + sin( radians(153) ) * sin( radians( latitude ) ) ) ) AS distance FROM Postcode HAVING distance < 25 ORDER BY distance

    any ideas as I really need the distance < 25 part so users can search by distance

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,571
    Rep Power
    595
    Copying someone else's bad code from the internet is always a bad thing. Is this really a PHP question or did you mean to post this in the MySQL forum instead? If PHP, you need to post your code (after reading the sticky at the top of this page about [ PHP ] tags).
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by gw1500se
    Copying someone else's bad code from the internet is always a bad thing. Is this really a PHP question or did you mean to post this in the MySQL forum instead? If PHP, you need to post your code (after reading the sticky at the top of this page about [ PHP ] tags).
    ok i will post this in mysql
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0

    MySql Query Help


    Hi professionals.

    i am new to php and mysql and I am trying to query my database to calculate the distance with the help from google develpoer instructions on this page.

    https :// developers.google.com/maps/articles/phpsqlsearch_v3

    when I try to query my database with the following query as advised by them no results are returned. here is my query, I think it is because of the order of exectuion of sql statement and it does not recognise the "distance" column name

    SELECT suburb, state, latitude, longtitude, ( 6371 * acos( cos( radians(153) ) * cos( radians( latitude ) ) * cos( radians( longtitude ) - radians(-27) ) + sin( radians(153) ) * sin( radians( latitude ) ) ) ) AS distance FROM Postcode HAVING distance < 25 ORDER BY distance

    any ideas as I really need the distance < 25 part so users can search by distance

    thanks
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0

    Longitude and latitude help


    Hi All


    I am looking to pull from my table everything within 30 kilometers of my latitude and longitude can this be done


    Postcode:4130 suburb:CARBROOK state: QLD latitude:
    -27.687086 longitude: 153.276026

    the query i have which doesnt work is

    SELECT postcode,suburb,state,latitude, 6731.0 * ACOS( SIN(-27.831402*PI()/180 ) * SIN(-27.831402*PI()/180 ) + COS(-27.831402*PI()/180 ) * COS(-27.831402*PI()/180 ) * COS( (153.028469*PI()/180) - (153.028469*PI()/180) ) ) AS distance
    FROM Postcode
    HAVING distance<=30 ORDER BY distance ASC

    any ideas

    thanks

IMN logo majestic logo threadwatch logo seochat tools logo