我已經被從我的數據庫查詢返回的以下數據:格式化MySQL查詢數據到自定義陣列
+---------------+-----------+------------------+--------------+-------+ | district_name | school_id | school_name | section | score | +---------------+-----------+------------------+--------------+-------+ | My ISD | 11 | My First School | English | 20 | | My ISD | 11 | My First School | Math | 23 | | My ISD | 11 | My First School | Reading | 24 | | My ISD | 11 | My First School | Science | 23 | | My ISD | 12 | My Second School | English | 11 | | My ISD | 12 | My Second School | Math | 19 | | My ISD | 12 | My Second School | Reading | 22 | | My ISD | 12 | My Second School | Science | 26 | +---------------+-----------+------------------+--------------+-------+
我需要把這個數據放到一個數組可以輕鬆地輸出由學校成績表:
School English Math Reading Science ------------------------------------------------------- My First School 20 23 24 23 My Second School 11 19 22 26
我在將這些數據格式化爲完成此操作的數組時遇到問題。理想的結構是:
array(
$schoolName => array(
'results' => array(
'section' => $section_name
'score' => $score
),
),
);
我已經嘗試了幾種方法,但無法讓它們正常工作。
你是什麼意思,你不能讓他們正常工作?出了什麼問題?有錯誤嗎?數據丟失了? – 2010-01-27 19:43:55