我想制作一个类似的系统,这就是我到目前为止所拥有的。我不知道如何让它只增加一次,有人可以帮助我吗?我觉得我可能必须使用会话变量,但我不确定。索引.php
<?php
$con = mysqli_connect('localhost', 'root', '','phplikes');
$query = "SELECT * FROM meme_vote ORDER BY vote DESC";
$res = mysqli_query($con, $query);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meme Voting System</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<?php while($row = mysqli_fetch_assoc($res)){ $location = $row['video_location'];?>
<div class="col-md-4">
<div class="post">
<h4 class="post-title"><?php echo $row['title']?></h4>
<div id="postdesign">
<video src="<?php echo $row['video_location'] ?>" width="100%" height="240" controls></video>
</div>
<a href="javascript:void(0)" class="btn btn-info btn-lg">
<span class="glyphicon glyphicon-thumbs-up " onclick="like_update('<?php echo $row['id']?>')">Vote
(<span id="like_loop_<?php echo $row['id']?>"><?php echo $row['vote']?></span>)
</span>
</a>
</div>
</div>
<?php }?>
</div>
</div>
另外只是为了让您知道,我已经建立了会话变量,即。$_SESSION['user_id']和 `$_SESSION['用户名']
BIG阳
相关分类