我試圖創建動態象下面這樣使用PHP創建陣列動態
$data = array(
array("date" => "1/2/2012", "sentstatus" => "0", "mobile" => "14578998"),
array("date" => "21/2/2012", "sentstatus" => "1", "mobile" => "14668998"),
array("date" => "1/5/2012", "sentstatus" => "1", "mobile" => "14598998"),
array("date" => "1/6/2012", "sentstatus" => "0", "mobile" => "14578748"),
);
下面的數組是插入SQL Server數據到數組我的PHP代碼,但問題是,它的陣列中只形成數據庫表的最後結果集行。我沒有得到這個想法插入所有數據庫錶行到數組如上圖所示:
$sql = "SELECT [start_date_time],[sent_status],[mobile_number] ,[play_file]
FROM [slice].[dbo].[tbl_message_detail] ";
$res = odbc_exec($con,$sql) or die(odbc_error());
$rows = odbc_num_rows($res);
while($row = odbc_fetch_array($res))
{
$data = array(
array("Date_Time" => $row['start_date_time'], "Send_Status" => $row['sent_status'], "Mobile_Number" => $row['mobile_number'], "play_file" => $row['play_file'])
);
}
改變'$ data'到'$數據[]' – diEcho 2012-02-22 06:22:03