我有一个登录表,该表有两个属性,userId 和 loginDate 我想要做的是当用户登录我的网站时向他显示他的最后登录日期
如果这是用户第一次登录,这意味着 loginDate 值为空,我只想插入当前日期,如果用户在我想更新日期之前已经登录。我该怎么做?到目前为止,我现在有这个
//..
$userId = $_POST['the_user'];
$query = "SELECT *
FROM login";
$result = mysqli_query($db, $query); //we make the query
if(empty($row[1]){ // THIS IS WHERE I INSERT A DATE IF THIS IS THE FIRST
// TIME A USER LOGS IN
$query = "INSERT INTO login(userId,loginDate)
VALUES ('$userId',CURDATE())";
$result = mysqli_query($db, $query); //we make the query
}
else if{ // THIS IS WHERE I WOULD DO MY UPDATE
}