我對PHP相當陌生,我不知道如何處理數組。這裏是處理,我想添加到我的數據庫中獲得的三個或更多值的多維數組中,然後我想根據時間戳(其中一個值)對它們進行排序。之後,我想顯示所有的排序值。我似乎無法做到這一點,這裏的代碼如何將值插入到多維數組中,然後顯示它們?
$queryWaitingPatients = 'SELECT ArrivalTime, TargetTime, Order, Classification FROM exams WHERE (CurrentState = "Pending")';
$results = mysql_query($queryWaitingPatients) or die(mysql_error());
if (mysql_num_rows($results) == 0) {
echo '<p>There\'s currently no patient on the waiting list.</p>';
return;
}
while ($rows = mysql_fetch_array($results)) {
extract($rows);
//now is the part that I don't know, putting the values into an array
}
// I'm also not sure how to sort this according to my $TargetTime
asort($sortedTimes);
//the other part I don't know, showing the values,
感謝您的幫助!
**僅供參考**'訂單'是[保留字](http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html)。把它換成反引號或用另一個詞,例如「訂單」。 –
爲什麼不在你的sql查詢中使用ORDER BY?這樣數據就已經排序了。 –