0
我的代碼生成陣列的動態
$records = array();
$records["data"] = array();
foreach ($rows as $row) {//select from DB
$records["data"][] =array();//XXXX
foreach($this->t_data['columns'] as $column) {//columns for table
$records['data'][][]=$row[$column['name']];//THIS need to add into XXXX array
}
}
$records["draw"] = $sEcho;
return json_encode($records);
這部分在嘗試以多種方式將數據添加到陣列。此代碼來自數據表。
這wotking代碼,靜態
foreach ($tickete as $row) {
$records["data"][] = array(
'<input type="checkbox" name="idticket" value="' . $row['id'] . '">',
$row['name'],
$row['type'],
$row['state']
);
}
格式:
{"data":[
["ID1","Name","Type","State"],
["ID2","Name","Type","State"],
["ID3","Name","Type","State"],
["ID4","Name","Type","State"],
["ID5","Name","Type","State"]],"draw":2,"recordsTotal":50,"recordsFiltered":50}
你想要的陣列格式? –
我編輯問題 –