$days = date('Y-m-d ', mktime($count['time_in']));
$date_today = date('Y-m-d');
if ($days != $date_today) {
$sql = "INSERT INTO login_details (time_in, user_id) VALUES (CURRENT_TIMESTAMP, '".$_SESSION['user_id']."') ";
$result = mysql_query($sql);
} else{
echo "<h3 align=center>Already exist!</h3>";
header ('refresh: 3; URL = index.php?page=timerecord');
}
答案 0 :(得分:-2)
time_in列应该在数据库中应该是datetime数据类型。
$date_today = date('Y-m-d');
$selectSql=mysql_query("SELECT count(*) as logincount from login_details where time_in=date(now())");
$countLogin=mysql_result($selectSql,0,'logincount');
if($countLogin>0){
} else {
$sql = mysql_query("INSERT INTO login_details (time_in, user_id) VALUES ('".$date_today."', '".$_SESSION['user_id']."')");
}