-1
MySQL查詢返回我一個多維數組:在PHP傳遞多維數組
function d4g_get_contributions_info($profile_id)
{
$query = "select * from contributions where `project_id` = $profile_id";
$row = mysql_query($query) or die("Error getting profile information , Reason : " . mysql_error());
$contributions = array();
if(!mysql_num_rows($row)) echo "No Contributors";
while($fetched = mysql_fetch_array($row, MYSQL_ASSOC))
{
$contributions[$cnt]['user_id'] = $fetched['user_id'];
$contributions[$cnt]['ammount'] = $fetched['ammount'];
$contributions[$cnt]['date'] = $fetched['date'];
$cnt++;
}
return $contributions;
}
現在我需要在我呼籲這個功能的頁面打印值。我怎麼做 ?
讀有關的foreach,然後你可以做其他的foreach裏面的foreach。 –
mamdouh alramadan, 你能幫我進一步,我嘗試了應用嵌套的for_each循環,但沒有任何進展。 – user2267386
你不需要先指定$ cnt ++ = 0的值嗎? –