connect_error) {
die("连接失败: " . $conn->connect_error);
}
// 查询数据
$sql = "SELECT id, name, email FROM users WHERE id=1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " . $row["email"]. "
"; } } else { echo "0 结果"; } // 修改数据 $sql = "UPDATE users SET email='newemail@example.com' WHERE id=1"; if ($conn->query($sql) === TRUE) { echo "记录更新成功"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?>
"; } } else { echo "0 结果"; } // 修改数据 $sql = "UPDATE users SET email='newemail@example.com' WHERE id=1"; if ($conn->query($sql) === TRUE) { echo "记录更新成功"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?>
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-