伙计们,我从事类似音乐的系统工作已有一段时间了,在有人点击按钮后,它会更新系统,但是在我这方面,它并没有在数据库中更新。但是,请输入我的代码。
<?php
DEFINE("IN_MUSICZOOM", 1);
// MusicPlus Page System - Index
require_once('inc/config.php');
$action = isset($_GET['action']) ? $_GET['action'] : '';
$songID = isset($_GET['songID']) ? $_GET['songID'] : '';
$artistID = isset($_GET['artistID']) ? $_GET['artistID'] : '';
$action = $_GET['action'];
$songID = $_GET['songID'];
// Load Music
$loadSongs = $db->fetchAll('SELECT * FROM songs WHERE songID = ?', array($songID));
if($loadSongs) {
foreach($loadSongs as $loadSong) {
$songID = $loadSong['songID'];
$slug = $loadSong['slug'];
$songName = $loadSong['songName'];
$songViews = $loadSong['songViews'];
$genres = $loadSong['genres'];
$songDescription = $loadSong['songDescription'];
$songLikes = $loadSong['songLikes'];
$imgURL = $loadSong['imgURL'];
$songURL = $loadSong['songURL'];
$artistName = $loadSong['artistName'];
$artistID = $loadSong['artistID'];
}
}
$pageName = "".$artistName." - ".$songName."";
require_once('inc/header.php');
if($action == "songliked") {
if(!empty($songID)) {
$db->update('UPDATE `songs` SET songLikes = songLikes + 1 WHERE songID = ?', array($songID));
header('Location: index.php?action=liked');
}
}
?>
答案 0 :(得分:0)
当我更改代码时,我发现了问题
if($action == "songliked") {
if(!empty($songID)) {
$db->update('UPDATE `songs` SET songLikes = songLikes + 1 WHERE songID = ?', array($songID));
header('Location: index.php?action=liked');
}
为此,在您按下按钮后就可以使用
if($action == "songliked") {
$db->update('UPDATE `songs` SET songLikes = songLikes + 1 WHERE songID = ?', array($songID));
header('Location: index.php?action=liked');
}