此代码将在后台运行,所以我想从数据库中自动获取特定的用户(ID),而无需手动进行操作。
(我有一个php脚本实际上可以做到这一点,但我必须手动输入UserID。解决方案?)
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "webdata";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// php update script
$sql = "UPDATE users SET RegistardDate = NOW() WHERE UserID=18";
// success or error message
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>