我知道这个问题已被多次询问,但我还没有真正找到我的代码的解决方案。 我选择供应商和年份,我想显示所有产品的清单。 对于某些供应商而言,它可以正常工作,但对于其他供应商则无效
经过多次测试后,我发现我的代码适用于所有供应商,除了供应商名称带引号和上限。
这是我的错误:
“轴#0的数据列不能是字符串”
代码:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Month', 'Product', 'Items'],
<?php foreach ($my_data as $a => $b): ?> ['<?php echo $month[$b['
month ']]?>', <?php echo $b['product'] ?>, <?php echo $b['items'] ?>,
],
<?php endforeach; ?>
]);
var options = {
title: 'supplier',
hAxis: {
title: 'product supplier',
titleTextStyle: {
color: '#333'
}
},
vAxis: {
minValue: 0
}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
这是我的疑问:
if(isset($_POST['$value1'] ))
{
$month = array('','January','February ','March','April','May','June','July','August','September','October','November','December');
$value1 = $_POST['$value1'] ;
$value2 = $_POST['$value1'] ;
$sql=" SELECT
name,
count(items),
MONTH(created_at) as month,
YEAR(created_at) as year,
sum(product) as product
FROM `supplier_product`
where
name = '".$value1."' and YEAR(date.created_at) = '".$value2."'
GROUP BY name,month
ORDER BY month ASC
";
这是我的代码PHP:
<label for="supplier"> Select name : </label>
<select name = "value1" id="sup">
<?php
$sql = "SELECT name FROM supplier_product";
$req = $mydatabase->prepare($sql);
$req->execute();
$data = $req->fetchAll(PDO::FETCH_ASSOC);
foreach ($data as $a => $b):
?>
<option value="<?php echo utf8_encode($v['name']); ?>"><?php echo utf8_encode($v['name']); ?></option>
<?php
endforeach;
?>
</select>
<select name= "value2">
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2014">2013</option>
<option value="2014">2012</option>
<option value="2014">2011</option>
<option value="2014">2010</option>
<option value="2014">2019</option>
</select>
请帮帮我。 非常感谢您的帮助。
答案 0 :(得分:2)
以下是我的问题的解决方案,我现在添加了JSch connection = new JSch();
Session session = connection.getSession(user, ip, port);
session.setPassword(password);
session.connect(15000);
ChannelExec channel = (ChannelExec) session.openChannel("exec");
//exec commands whit channel
Channel ch;
ch = ssh.session.openChannel("sftp");
ch.connect();//-------ERROR!
ChannelSftp sftp = (ChannelSftp)ch;
和addslashes
。
utf8_decode
答案 1 :(得分:-1)
将MethodNotAllowedHttpException
个变量放在php
变量中,然后parse将它们作为整数放置,它应该可以正常工作。 javascript
无法使用字符串执行计算。
Google Charts
EDIT2:增加了第二个例子。
var month = parseInt(<?= $month; ?>, 10);
然后在图表中使用var products = [];
//your loop here
products[key] = <?= $b['product']; ?>;
products[key].replace(/["']/g, "");
//end loop
变量'产品'。