Hi,all
Here is the sql sentence i wrote on my php file.
But when i test with it nothing show up which there should have some results??
My idea is :get the sw and ne point, choose every value live inside the rectangle in my database

//zips is my table in the phpmyadmin
//$swlat and $swlng are both float format, same format in //$nelat,$nelng
$sql = "SELECT ZipCode FROM zips 
            WHERE Latitude BETWEEN '$swlat' AND '$nelat'
            AND  Longtitude BETWEEN '$nelng' AND '$swlng'
            ORDER BY Population DESC LIMIT 5";

Many Thanks

Recommended Answers

All 3 Replies

Does your mysql_query call return 0 rows or does it throw an error?

Return zero rows
No error show up

If it returns 0 rows but there isn't an error than its just that. Nothing matches the conditions you're giving it. Trying making your condition less specific until you get a result and then narrowing it down again. Ie.,

SELECT ZipCode FROM zips ORDER BY Population DESC LIMIT 5

Then

SELECT ZipCode FROM zips 
  WHERE Latitude BETWEEN '$swlat' AND '$nelat'
  ORDER BY Population DESC LIMIT 5

etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.