0

请我的代码有问题。我打算选择我的数据库中的所有详细信息并循环创建一个表。但我不断收到此错误:

警告: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';
}
4

0 回答 0