Nezmínili jste pole telefonního čísla, takže jsem předpokládal, že je phone_number
:
$db = new PDO('mysql:host=localhost;dbname=testdb;charset=UTF-8', 'username', 'password', array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
if (isset($_REQUEST['data'])){
$data = json_decode($_REQUEST['data']);
if($data->phonenumber){
$stmt = $db->prepare("SELECT `id` FROM `test` where `id`=:phone_number");
$stmt->execute(array(':phone_number' => $data->phonenumber));
$row_count = $stmt->rowCount();
if($row_count && ($data->phonenumber != '')){
$stmt = $db->prepare("UPDATE `test` SET `longitude`=:longitude, `latitude`=:latitude, `timestamp`=:timestamp WHERE `id`=:phone_number");
$stmt->execute(array(':longitude' => $data->longitude,':latitude' => $data->latitude,':timestamp' => $data->timestamp,':phone_number' => $data->phonenumber));
}
}
}