2013-12-11 80 views
0

我有我的PHP代碼的問題。 我不能編碼在我的DB 我所有的紀錄這是我的PHP代碼:JSON編碼從PHP

$out = array(); 
while ($row3 = mysql_fetch_array($res3)){ 
array_push($out, array('nomi_partecipanti' => $row3['nomi_partecipanti'], 'importo' => $row3['importo'], 'Stato' => $row3['options'])); 

    print(json_encode($out)); 

} 

我希望輸出JSON是類似的東西:

[{"nomi_partecipanti":alex,"importo":"100","Stato":"pagato"},{"nomi_partecipanti":mark,"importo":"300","Stato":"pagato"}]} 

預先感謝您。

+0

什麼是'打印(json_encode($出))之外的'返回的權利嗎? –

+0

是我的JS的印刷品。 – Reverter

回答

0

認沽json_encode以外的while循環

$out = array(); 
    while ($row3 = mysql_fetch_array($res3)){ 
    array_push($out, array('nomi_partecipanti' => $row3['nomi_partecipanti'], 'importo' => $row3['importo'], 'Stato' => $row3['options'])); 



    } 

     echo json_encode($out); 
0

把你的輸出的同時

$out = array(); 
while ($row3 = mysql_fetch_array($res3)){ 
    array_push($out, array('nomi_partecipanti' => $row3['nomi_partecipanti'], 'importo' => $row3['importo'], 'Stato' => $row3['options'])); 
} 
print(json_encode($out));