0
$qry = "SELECT user, TIME_FORMAT(last_login_time, '%H:%i') FROM login_attempts WHERE user = '".$username."'";
$result = mysql_query($qry,$this->connection);
if(!$result || mysql_num_rows($result) <= 0){
mysql_query ("INSERT INTO login_attempts(userid, user, attempts, last_login_time) VALUES('', '$username', '{$_SESSION['count']}', '{$_SESSION['login_time']}')");
}
else{
$row = mysql_fetch_assoc($result);
$_SESSION['login_time'] = $row["last_login_time"];
mysql_query ("UPDATE login_attempts SET attempts = '" .$_SESSION['count']."' WHERE user = '".$username."'");
}
取时间戳mysql的值在上面的代码我存储我的“login_attempts
”表,其中列名是“last_login_time” $_SESSION['login_time']
值。
现在我需要获取该值并将其存储回$_SESSION['login_time']
数组中,以便我了解用户上次尝试输入的时间。我应该如何取这个值?
'last_login_time'
列的数据类型是'timestamp'.
[**请不要在新代码中使用'mysql_ *'函数**](http://bit.ly/phpmsql)。他们不再被维护[并且被正式弃用](http://j.mp/XqV7Lp)。看到[**红框**](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。 – Kermit 2013-03-22 15:46:15