我正在使用PHP从我的mysql数据库中提取mp3文件位置,并希望将这些变量传递给我页面中的脚本。
我想知道如何从我的数据库中的数组中获取以下文件名:
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
m4a: "downloads/uploads/p170f0vflo1066jbc1l4pp38st01.mp3",
}, {
cssSelectorAncestor: "#cp_container_1",
swfPath: "js",
wmode: "window"
});
所以我需要这样的东西:
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
m4a: "<?php echo $music_p; ?>", <---This is what I need (from a database)
}, {
cssSelectorAncestor: "#cp_container_1",
swfPath: "js",
wmode: "window"
});
答案 0 :(得分:0)
正如@Sean Johnson所说,如果你在与javascript相同的文件中定义$ music_p,它应该可以工作。例如,在javascript标签
中<?php $music_p = array("downloads/uploads/p170f0vflo1066jbc1l4pp38st01.mp3") ?>
<script type="text/javascript">
//JavaScript code (define functions here)
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
m4a: "<?php echo $music_p[0]; ?>", <----------This is what i want!
}, {
cssSelectorAncestor: "#cp_container_1",
swfPath: "js",
wmode: "window"
});
</script>
我相信这是你可能想要看到的。