-1
我有一個表tem_test
在這個表中一個字段是start_time
其中有DATETIME
數據類型,我想比較這個日期和當前日期時間;如果時間大於30分鐘選擇獲取數據....計算分鐘mysql和php的時差
like
if(user passed 30 minute)
{
// then update other table with user's info where userid ='user who crossed the 30 minute';
}
else
{
// do sometihing ....
}
<?php
<?php
$intranet_connect = mysql_connect('localhost','root',''); //create connection to intranet host
$radius_connect = mysql_connect('localhost','root',''); //creates connection to radius
mysql_select_db('db_intranet',$intranet_connect); //using db_intranet database with $intranet_connect host connection
$query = mysql_query('SELECT username,srvid,start_time FROM temp_day_test WHERE status="yes"',$intranet_connect); //check if service is on test mode then perform...below
while($row = mysql_fetch_assoc($query)) //fetch selected data from table
{
$data[]=$row;
}
$data['srvid']= $srvid; //hold service id in $srvid
$data['username'] = $username;
$data['start_time']=$startTime;
$currentTime = date('Y-m-d H(idea)(worry)'); //create current date time with timezone Asia/kathmandu. NOTE: set time zone in PHP.INI, default.timezone=Asia/Kathmandu
$timeDifference = (strtotime($currentTime) - strtotime($startTime)); //Calculate time difrence between test start time and test end time
if($timeDifference >1800)// if time exceeds 30 minute then...
{
echo $data['username'];
echo $data['srvid'];exit;
mysql_select_db('radius',$radius_connect); //select radius database
$query = mysql_query('UPDATE rm_users SET srvid="'.$srvid.'" WHERE srvid= 44 ', $radius_connect);
if(!$query)
{
die(mysql_error());
}
}
?>
如果我在mydatabase上試過任何東西,你應該總是嘗試一些東西,然後在這裏發帖 – 2014-09-03 08:02:59
,我的compny會丟失evrything ... – 2014-09-03 08:03:56