我正在尝试使用AmCharts制作图表,并在他们的网站上关注此示例:https://www.amcharts.com/kbase/using-data-loader-to-connect-charts-to-mysql-data-base/
我的原始代码是
var chart = AmCharts.makeChart("chart_1", {
"pathToImages": App.getGlobalPluginsPath() + "amcharts/amcharts/images/",
"dataProvider": [{
"year": 2009,
"income": 23.5,
"expenses": 18.1
}, {
"year": 2010,
"income": 26.2,
"expenses": 22.8
}],
// bunch of graph stylings
});
$('#chart_1').closest('.portlet').find('.fullscreen').click(function() {
chart.invalidateSize();
});
}
Run Code Online (Sandbox Code Playgroud)
我尝试从mysql加载数据
var chart = AmCharts.makeChart("chart_1", {
"type": "serial",
"dataProvider": {
"url": "data.php"
},
"pathToImages": App.getGlobalPluginsPath() + "amcharts/amcharts/images/",
// bunch on graphs style
});
$('#chart_1').closest('.portlet').find('.fullscreen').click(function() {
chart.invalidateSize();
});
}
Run Code Online (Sandbox Code Playgroud)
包含硬编码数据的原始代码正在运行.下面用mysql不起作用.它是空白页面,不显示图表.控制台上也没有错误.
data.php 正在工作并返回json数组.
有人可以帮忙吗?
如果还需要php部分
$query = "
SELECT *
FROM …Run Code Online (Sandbox Code Playgroud) 我正在尝试在处理表单时插入日期,但是在MySQL中插入就像
0000-00-00
我不希望用户插入日期.这是我的表格
<form action="upload.php" method="post" enctype="multipart/form-data">
<textarea type="text" name="text" cols="40" rows="10"></textarea><br />
<input type="hidden" name="dt"/>
<input type="submit" name="upload" id="upload" value="???????" />
Run Code Online (Sandbox Code Playgroud)
这是upload.php
<?php
if (isset($_POST['upload'])) {
$text = $_POST['text'];
$dt = date('Y-m-d', strtotime($_POST['Date']));
$db = new mysqli("localhost", "*****", "", "****");
if (mysqli_connect_error()) {
printf("Connect failed: ", mysqli_connect_error());
}
mysqli_set_charset($db, "UTF8");
$query = "INSERT INTO table (text, date) VALUES (?, ?)";
$conn = $db->prepare($query);
if ($conn == TRUE) {
$conn->bind_param("si",$text, $dt );
if (!$conn->execute()) {
echo 'error insert';
} else …Run Code Online (Sandbox Code Playgroud)