我正在尝试将事件从数据库提取到日历,但在此阶段它只输出从数据库获取的第一个事件和json,当我回显它时它只返回第一个事件
<?php
include("dbcon.php");
$events1 = array();
$sql345="select * from takimet";
$result = mysql_query($sql345)or die(mysql_error());
while ($row=mysql_fetch_array($result)){
$id = $row['agent_id'];
$title = $row['ezitimi'];
$start = $row['datestamp'];
$events1 = array(
'id' => "$id",
'title' => "$title",
'start' => "$start"
);
}
echo json_encode($events1);
?>
答案 0 :(得分:1)
你每次循环都在编写相同的数组。
相反
$events1 = array();
while ($row=mysql_fetch_array($result)){
$events1[] = array( //<--- changed
'id' => $row['agent_id'],
'title' => $row['ezitimi'],
'start' => $row['datestamp']
);
}