我是西蒙,刚开始学习PHP时我是学生。
实际上,这个程序试图从一个名为跟踪的数据库中检索信息,并查询来自SenderNumber = +0139760095
的行,'readed'=false
。
在找到满足上述要求的行之后,sql命令将SELECT
并开始过滤并计算检索到的消息。
最后,我将LATEST VALUE保存到名为markers1
的数据库中。
以下是我的计划,请看一下,谢谢:
<?php
//to show the GPS data
$con=mysql_connect("localhost","root","");
if (!$con) {
die ('cannot connect:'.mysql_error()); }
$SenderNumber = '+60109760095';
mysql_select_db("kalkun", $con);
$result = mysql_query("SELECT * FROM inbox where SenderNumber = '$SenderNumber' && readed= 'false' ");
**//////ALL THE query result like GSr,011412001293574,2,1,00,,1....... will put into str to be filer up.**
//function and way to cut out the message
$str = 'GSr,011412001293574,2,1,00,,1,090211,062123,E11150.6772 ,N0218.8778,0,0.33,348,2,0.0,66*5e!';
$array = explode_trim($str);
function explode_trim($str,
$delimiter = ',') {
if ( is_string($delimiter) ) {
$str = trim(preg_replace('|\\s*(?:' . preg_quote($delimiter) . ')\\s*|',
$delimiter, $str));
return explode($delimiter, $str);
}
return $str;
}
//cut out message end
echo("<br />"); $imei = $array[1];
echo("<br />"); $datetime = $array[7] . $array[8];
echo("<br />"); $lng = $array[9];
echo("<br />"); $lat = $array[10];
print_r($lat);
echo("<br />"); $altitude = $array[11];
echo("<br />"); $speed = $array[12];
echo("<br />"); $heading = $array[13];
echo("<br />"); $NoOfSat = $array[14];
echo("<br />");
echo("<br />");
function getlat($lat) {
$gpslat = substr($lat, 1, 2);
$gpslat2 = substr($lat, 3, 7);
$Nwlat= $gpslat + ($gpslat2/60);
//print_r($Nwlat); //echo("<br />");
return $Nwlat;
}
echo("<br />");
function getlng($lng) {
$gpslng = substr($lng, 1, 3);
$gpslng2 = substr($lng, 4, 7);
$Nwlng= $gpslng + ($gpslng2/60);
return $Nwlng;
}
//print_r(getlng($lng));
echo("<br />"); $abc="";
function Lttimedate($datetime) {
echo("<br />");
$format = 'dmy Gis';
$NewDateTime = DateTime::createFromFormat(
$format,
$datetime, new DateTimeZone("Asia/Kuala_Lumpur"));
$NewDateTime ->add(new DateInterval('P0Y0M0DT8H1M1S')
);
//echo "Format: $format; " .
$NewDateTime ->format('Y-m-d H:i:s') . //"\n"; return $NewDateTime
->format('Y-m-d H:i:s');
}
echo("<br />"); //print_r($latesttime); $latesttime =
Lttimedate($datetime);
$latestlat = getlat($lat);
$latestlng = getlng($lng);
**////save the latest vallue into markers(datanase name)**
function updateToDb($SenderNumber,
$latestlat, $latestlng ,$latesttime
){
$con=mysql_connect("localhost","root","");
if (!$con) {
die ('cannot connect:'.mysql_error()); }
mysql_select_db("tracking", $con); $result = mysql_query("SELECT
* FROM inbox where SenderNumber = '$SenderNumber' && readed= 'false'
");
} ?>
<script type="text/javascript">
</script>
</html>