在图表中插入行数

icomxhvb  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(351)

我该怎么做才对呢?我已经找了很长时间了,找不到我问题的确切答案。我可以很好地回显$rowcount1和$rowcount2的内容,并希望在图表数据中使用它。

<!DOCTYPE HTML>
<html>
<head>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script type="text/javascript">

window.onload = function () {
	var chart = new CanvasJS.Chart("chartContainer", {
		title:{
			text: "LIST RECORD"              
		},
		data: [              
		{
			type: "column",
			dataPoints: [
				{ label: "Sold",  y: '$rowcount1'  },        //Properly insert count?
				{ label: "Rejected", y: '$rowcount2'  },     //Properly insert count?
			]
		}
		]
	});
	chart.render();
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 60%;"></div>
</body>
</html>

    <?php
error_reporting(0);
// connect to the database
$conn = mysqli_connect("localhost", "root", "", "order");
$sql="SELECT * FROM order.item WHERE status IN ('Sold')";
if ($result=mysqli_query($conn,$sql))
  {
  $rowcount1=mysqli_num_rows($result);
  mysqli_free_result($result);
  }
mysqli_close($conn);
?>

<?php
error_reporting(0);
// connect to the database
$conn = mysqli_connect("localhost", "root", "", "arc");
$sql="SELECT * FROM order.item WHERE status IN ('Rejected')";
if ($result=mysqli_query($conn,$sql))
  {
  $rowcount2=mysqli_num_rows($result);
  mysqli_free_result($result);
  }
mysqli_close($conn);
?>

我该怎么办?谢谢你们!

wwodge7n

wwodge7n1#

知道了。我只需要重新安排我的代码。干杯!

相关问题