php/ajax 投票赞成反对
php/ajax vote up down
请提前注意,因为我是新来的,而且我在 php/ajax 编码方面完全是新手。
我使用来自this site
的免费脚本(Ajax投票up/down)
我有一个简单的 php 页面供我的 shoutcast 服务器显示播放的歌曲
<?php
require_once "inc.php";
$array = array(); // Let's store our shoutcast variables into an array.
$array['host'] = "xxx.xxx.xx.xxx"; // Your Shoutcast Host
$array['port'] = "xxxx"; // Your Shoutcast Port
$array['extra'] = "/admin.cgi?sid=1&mode=viewxml&page=1"; // The bit that follows in the url to access the xml of the stats
$array['user'] = "xxxxx"; // Admin username (Default is usually "admin")
$array['password'] = "xxxxxxx"; // Admin Password
$radioStats = new radioStats( $array['host'], $array['port'], $array['extra'], $array['user'], $array['password']);
$returnStats = $radioStats->returnStats();
$song = $returnStats['currentSong'];
?>
<div align="center">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<link href="votingfiles/voting.css" rel="stylesheet" type="text/css" />
<script src="votingfiles/voting.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
setInterval(function(){cache_clear()},54000);
});
function cache_clear()
{
window.location.reload(true);
}
</script>
<div id="radio_stats">
<?php
if( $returnStats['serverStatus'] != 0 ) {
?>
<?php
if( $returnStats['currentSong'] != "" ) {
echo $returnStats['currentSong'];
} else {
echo "Undefined";
}
?></div>
<br /><br />
<div class="vot_updown1" id="vt_$song"></div>
<?php
}
else {
?>
This radio server appears to be offline.
<?php
}
?>
我的问题是:
所有请求 Php/ajax/mysql 都有效,但实际上当我投票时,它在数据库中注册为:
vt_$歌曲 1 0
我怎样才能像最初的 php 请求那样获得歌曲的真实名称:
echo $returnStats['currentSong']; 或 echo $song;
像这样在数据库中注册:
vt_Kidd Guti-Step Everything 1 0(或播放的任何其他歌曲)
示例:[此处]
在此先感谢您的帮助。
在这一行中,$song
未被解析为 PHP,因此文字文本 $song
显示为:
<div class="vot_updown1" id="vt_$song"></div>
尝试:
<div class="vot_updown1" id="vt_<?php echo $song; ?>"></div>
请提前注意,因为我是新来的,而且我在 php/ajax 编码方面完全是新手。
我使用来自this site
的免费脚本(Ajax投票up/down)我有一个简单的 php 页面供我的 shoutcast 服务器显示播放的歌曲
<?php
require_once "inc.php";
$array = array(); // Let's store our shoutcast variables into an array.
$array['host'] = "xxx.xxx.xx.xxx"; // Your Shoutcast Host
$array['port'] = "xxxx"; // Your Shoutcast Port
$array['extra'] = "/admin.cgi?sid=1&mode=viewxml&page=1"; // The bit that follows in the url to access the xml of the stats
$array['user'] = "xxxxx"; // Admin username (Default is usually "admin")
$array['password'] = "xxxxxxx"; // Admin Password
$radioStats = new radioStats( $array['host'], $array['port'], $array['extra'], $array['user'], $array['password']);
$returnStats = $radioStats->returnStats();
$song = $returnStats['currentSong'];
?>
<div align="center">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<link href="votingfiles/voting.css" rel="stylesheet" type="text/css" />
<script src="votingfiles/voting.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
setInterval(function(){cache_clear()},54000);
});
function cache_clear()
{
window.location.reload(true);
}
</script>
<div id="radio_stats">
<?php
if( $returnStats['serverStatus'] != 0 ) {
?>
<?php
if( $returnStats['currentSong'] != "" ) {
echo $returnStats['currentSong'];
} else {
echo "Undefined";
}
?></div>
<br /><br />
<div class="vot_updown1" id="vt_$song"></div>
<?php
}
else {
?>
This radio server appears to be offline.
<?php
}
?>
我的问题是: 所有请求 Php/ajax/mysql 都有效,但实际上当我投票时,它在数据库中注册为:
vt_$歌曲 1 0
我怎样才能像最初的 php 请求那样获得歌曲的真实名称:
echo $returnStats['currentSong']; 或 echo $song;
像这样在数据库中注册:
vt_Kidd Guti-Step Everything 1 0(或播放的任何其他歌曲)
示例:[此处]
在此先感谢您的帮助。
在这一行中,$song
未被解析为 PHP,因此文字文本 $song
显示为:
<div class="vot_updown1" id="vt_$song"></div>
尝试:
<div class="vot_updown1" id="vt_<?php echo $song; ?>"></div>