2010-11-17 97 views
-2
$query="SELECT file_date,application,language,loc FROM table1 WHERE language!='total' AND module_id=306 ORDER by file_date"; 
    return(get_data($locdb_handler,$query)); 
} 

function get_data($handler,$qry){ 
    $result=mysql_query($qry,$handler); 
    while($row = mysql_fetch_array($result)){ 
    $data['data'][$row[0]]['data']['status'][$row[1]]+=$row[3]; 
    $data['total'][$row[0]]+=$row[3]; 
    } 

$ data ['data'] [$ row [0]] ['data'] ['status'] [$ row [1]] + = $ row [3] ; -----> 上面這行代表的是什麼。 有一個簡單的查詢....我想knw我們如何映射這...請幫助關聯數組邏輯--php

+2

那麼問題是什麼? – AndreKR 2010-11-17 13:04:06

回答

0

是的。在這個例子中,他們使用了關聯數組。

希望有所幫助。


你可能想,如果你想有一個真正的答案,以一個實際的問題添加到你的問題;)

0
$data['data'][$row[0]]['data']['status'][$row[1]]+=$row[3]; 
$data['total'][$row[0]]+=$row[3]; 

相同

$data['data'][$row['file_date']]['data']['status'][$row['appliction']]+=$row['loc']; 
$data['total'][$row['file_date']]+=$row['loc']; 

但它不是一個關聯數組,這意味着它使用字符串作爲數組鍵而不是數字。所以$ row [0]是查詢返回的第一列,$ row [1]是第二列,等等。