나는 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)입니다. 예를 들어, Backticks로 감싸거나 다른 단어 인 'Orders'를 사용하십시오. –
SQL 쿼리에서 ORDER BY를 사용하지 않는 이유는 무엇입니까? 이렇게하면 데이터가 이미 정렬됩니다. –