永发信息网

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

答案:2  悬赏:0  手机版
解决时间 2021-12-17 19:37
  • 提问者网友:做自己de王妃
  • 2021-12-17 13:28
<?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>
最佳答案
  • 五星知识达人网友:动情书生
  • 2021-12-17 14:09
和输出普通的html没有任何区别,例如<br>&lt;?php $a = array(1,2,3);?&gt;<br>&lt;script&gt;<br>&lt;?php foreach($a as $value):?&gt;<br>alert('&lt;?php echo $value?&gt;');<br>&lt;?php endforeach;?&gt;<br>&lt;/script&gt;
全部回答
  • 1楼网友:拾荒鲤
  • 2021-12-17 15:34
没看懂什么意思?
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯