calculate distance from Latitude and Longitude google map


SELECT  ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;

more help
http://www.movable-type.co.uk/scripts/latlong.html
Advertisements

Get the unique id created after insert command of a record


This is mysql query in php code. After executing this code, the query returns latest auto generated number for that query.
$query=mysql_query(“insert into help_desk(userid,type,domain,detail) values(‘$userid’,’$type’,’$domain’,’$detail’)”);

/* Note that here auto increment field is not shown as it automatically add the next incremented value with every insert command */

echo “Your trouble ticket number is = ” mysql_insert_id();