1 回答
TA贡献1871条经验 获得超8个赞
您需要将用户 ID 放入表单中,并在插入时使用。
此外,表格需要在里面<body>,而不是在它之后。
<?php
include_once 'session.php';
include_once 'dbh.php';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="cs.css">
</head>
<body>
<?php
$sql = "SELECT * FROM users ORDER BY RAND () LIMIT 1 ; ";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck> 0){
$row = mysqli_fetch_assoc($result);
$ide = $row['idUsers'];
?>
<form action ="" method="post">
<button value = "<?php echo $ide; ?>" name="like">like</button>
</form>
<?php
}
- 1 回答
- 0 关注
- 85 浏览
添加回答
举报