0

我正在使用 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"
});
4

1 回答 1

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>

我相信这是你可能想看的。

于 2012-06-25T00:01:42.753 回答