I have a little php script that goes to mySql database.
I want to look, before i insert a new record in the database, if the number (value1) equals a record in the database. Wich is also in Row1.
So i want to:
- Look if the phone number that comes in equals to a phone number in the database. If it does, than it must keep the phone number the same value, only update : longitude, latitude & timestamp.
- If the phone number equals null. Don’t put any of the values in my database. No records at all.
- If the phone number is not in the database, also do nothing. Repeat it just like the value is null.
Here’s my current PHP code, where i just make new records when there are any new values.
<?php
$con = mysql_connect('server', 'user_name', 'pass');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_name", $con);
if (isset($_REQUEST['data'])){
$json = $_REQUEST['data']; // recieve json from app
$data = json_Decode($json);
mysql_query("INSERT INTO test (id, longitude, latitude, timestamp) VALUES ('$data- >id','$data->longitude','$data->latitude','$data->timestamp')");
}
mysql_close($con);
?>
If anyone could help me with this, it would be appreciated!
Thanx
You didn’t mentioned the phone number field, so I assumed is
phone_number: