Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:54:20+00:00 2026-05-24T16:54:20+00:00

I have two tables: 1) One is the location table that is kept from

  • 0

I have two tables:

1) One is the location table that is kept from android phone consists of username, latitude, longitude, date, time.

2) Another one is table that I kept country, region, province, postal code, city, latitude, longitude.

I want to mapping location(lat,lng) of table 1) using table 2) before insert to db.
It’s look simple but the problem is location of table 2) is just a stable point, otherwise the location of table 1) are points which traversal of each city.
So, the location of table 1) is not similar to location of table 2).

Any one have idea for this problem ? Any formula or technique ?
Appreciate your help.

edit: I tried this statement before insert statement

$city  =  mysql_query("SELECT p.city
    FROM place AS p
    ORDER BY ACOS(SIN(p.lng)*SIN('".$lng."')+COS(p.lng)*COS('".$lng."')*COS(p.lat-'".$lat."'))",$con);

but the result is Resource id #3 in the field, other fields also shown like this.
c

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:54:22+00:00Added an answer on May 24, 2026 at 4:54 pm

    so somthing like:

    SELECT regions.*
    FROM users, regions
    WHERE users.user_id = $user_id
    ORDER BY 
      ACOS ( 
        SIN(users.long) * SIN(regions.long) + 
        COS(users.long) * COS(regions.long) * COS(regions.lat - users.lat) 
      )
    LIMIT 1
    

    Added 2011-08-15

    or in php like your exemple

    $query  = "SELECT city
               FROM place
               ORDER BY
                 ACOS(
                   SIN(lng) * SIN({$lng}) +
                   COS(lng) * COS({$lng}) * COS(lat - {$lat})
                 )";
    $resource = mysql_query($query);
    $result = mysql_fetch_assoc($resource);
    $city = $result['city'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have two tables, one is a table of forum threads. It has a
I have two tables, one for values one for location and am trying to
Lets say I have two tables, one for transactions, and another table who's primary
I have two very large enterprise tables in an Oracle 10g database. One table
I have a two tables, one that contains basic resource info, with columns and
I have two different tables to track location of equipment. The equipment table tracks
I have two tables: one is ip_group_city from ipinfodb.com containing ip_start numbers for determining
I have two tables: locations and listings. locations id title address latitude longitude listings
I have two tables one has a three column composite key. The other needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.