我從數據庫中獲得值的第一件事沒有問題。然後我可以回顯值,但之後值變爲空。不知何故,這些值不會通過這一點。這是我的代碼。JavaScript不會回顯來自數據庫的值
PHP和MySQL部分
$rows = array();
$result = mysql_query("SELECT * FROM kayitlar");
$i=1;
while($row = mysql_fetch_array($result)) {
$rows []= array(
'id' => $row['id'],
'ad' => $row['ad'],
'saat' => $row['saat'],
);
$i++;
}
沒有問題,直到這一點。下面是我有問題,在這裏
<script type="text/javascript">
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "title"
},
animationEnabled: true,
axisY: {
title: "Zaman (saat)"
},
legend: {
verticalAlign: "bottom",
horizontalAlign: "center"
},
theme: "theme2",
data: [
{
type: "column",
showInLegend: true,
legendMarkerColor: "grey",
legendText: "saat",
dataPoints: [
{y:<?php echo json_encode($row['ad']); ?>, label: "<?php echo json_encode($row['saat']); ?> "},
]
}
]
});
chart.render();
}
</script>
的代碼的其餘部分在哪裏卡住<?php echo json_encode($row['ad']); ?>
越來越沒有價值
請勿使用*棄用和不安全*'mysql_ *'功能。從PHP 5.5(2013年)開始,它們已被棄用,並且在PHP 7中(2015年)完全刪除。改用MySQLi或PDO。 –
@MagnusEriksson如果他低於PHP 5.5 lol –
@OliverNi然後他應該_really_升級,因爲這些版本多年來都沒有得到支持。另外,您仍然可以在舊版本上使用MySQLI和PDO。無論您使用的是什麼PHP版本,「mysql_ *」功能都很差且不安全。 –