求助,如何让php数据在JS代码中循环输出。

<?phpinclude("inc/auth.php");include_once("inc/utility_all.php");include_once("inc/ut... <?php
include("inc/auth.php");
include_once("inc/utility_all.php");
include_once("inc/utility_org.php");

$query1="select * from bchaoraom where ctype=0 ORDER BY `bchaoraom`.`cdata` asc ";
$cursor= exequery($connection,$query1);
while($ROW=mysql_fetch_array($cursor))
{
$ctype=$ROW['ctype'];//类型
$cdata=$ROW['cdata'];//时间
$yue=substr($cdata,6);
$nian=substr($cdata,0,4);
echo $nian;
$cjiage=$ROW['cjiage'];//价格
}

?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Highcharts Example</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
type: 'spline'
},
title: {
text: '缠绕膜统计趋势报表'
},
subtitle: {
text: 'An example of irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%Y年%M月',
year: '%Y年'
}
},
yAxis: {
title: {
text: '价格(元)'
},
min: 0
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y年%m月', this.x) +': '+ this.y +' 元';
}
},

series: [{
name: '市场缠绕膜价格',
// Define the data points. All series have a dummy year
// of 1970/71 in order to be compared on the same x axis. Note
// that in JavaScript, months start at 0 for January, 1 for February etc.
data: [
[Date.UTC(2013,1),17 ],
[Date.UTC(2013,2),18 ],
[Date.UTC(2013,3),17 ],
[Date.UTC(2013,4),19 ],
[Date.UTC(2013,5),20 ],

]
}, ]
});
});
</script>
</head>
<body>
<script src="../../js/highcharts.js"></script>
<script src="../../js/modules/exporting.js"></script>

<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

</body>
</html>
展开
 我来答
百度网友a19d193
2013-04-19 · TA获得超过3446个赞
知道大有可为答主
回答量:1464
采纳率:100%
帮助的人:1441万
展开全部

和输出普通的html没有任何区别,例如

<?php $a = array(1,2,3);?>
<script>
<?php foreach($a as $value):?>
alert('<?php echo $value?>');
<?php endforeach;?>
</script>
追问
我是要将php数据写入
data: [
[Date.UTC(2013,1),17 ],
[Date.UTC(2013,2),18 ],
[Date.UTC(2013,3),17 ],
[Date.UTC(2013,4),19 ],
[Date.UTC(2013,5),20 ],

]
里面,但是我加php代码的时候就报错了
追答
贴出来看看啊,应该是你的具体代码出错了,不是因为不允许这样写。
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式