请问我的代码有问题。我打算在我的数据库中选择所有细节并循环创建一个表。 但我一直收到这个错误:
警告:mysql_fetch_assoc()要求参数1为资源,第10行的C:\ xampp \ htdocs \ donation_details.php中给出布尔值 没有找到捐赠记录
请帮忙。我会感激任何帮助。 感谢
$connect = mysql_connect("localhost","hifee","kalimat","hifee");
if(!$connect) die('Unable to fetch data');
else{
$donation = array();
$query = "SELECT * FROM tx_transaction";
echo $query;
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$donation[] = $row;
}
$total_records = count($donation);
if($total_records > 0){
echo '<table>';
echo '<tr>Transaction ID</td>
<td>Amount donated(=N=)</td>
<td>Donation date</td>
<td>Donation status</td>
<td>Response code</td>
<td>Meno</td>
<td>Response details</td>
<td>Donor\'s email</td>
</tr>';
foreach($donation as $value){
echo '<tr />
<td>'.$value['tx_id'].'</td>
<td>'.number_format($value['tx_amount'],2).'</td>
<td>'.$value['tx_date'].'</td>
<td>'.$value['tx_status'].'</td>
<td>'.$value['tx_response_code'].'</td>
<td>'.$value['tx_memo'].'</td>
<td>'.$value['tx_response_details'].'</td>
<td>'.$value['tx_buyer_email'].'</td>
</tr>';
}
echo '</table>';
}else echo 'No donation records found';
}