php代码检查当前日期并将当前时间戳插入mySQL

时间:2015-11-06 08:18:23

标签: php

<?php

if($_SERVER['REQUEST_METHOD']=='POST'){
 $staffID = $_POST['staffID'];

date_default_timezone_set("Asia/Singapore");

$checkInTime = $_SERVER['REQUEST_TIME'];
 $today = date('Y-m-d');

require_once('dbconnect.php');

$sqlcheck = "SELECT * FROM StaffAttendacne WHERE StaffID = '$staffID' AND Date ='$today'";

$sql = "INSERT INTO StaffAttendance (StaffID,Date,CheckInTime) VALUES ('$staffID','$today','$checkInTime')";

$result = mysqli_query($con,$sqlcheck);
 $check = mysqli_fetch_array($result);

if (isset($check)){
 echo "You have already checked in";
 }else {
 echo"$checkInTime";
 mysqli_query($con,$sql);
 }

如何编写php插入检查时间(插入时间戳)到SQL数据库中。时间是应用程序启动时间。我写了这段代码但没有用

1 个答案:

答案 0 :(得分:0)

您正在使用if (isset($check)){,因为您已在其上方$check定义mysqli_query($con,$sql);,因此您的if(count($check) > 0)未运行。

您应该使用 end.jmx(file: Dir.pwd+"/TestPlan.jmx") # Dir.pwd will give your current directory path