0

我正在尝试使用 php 显示来自 mysql 的数据。请找到我使用的代码。我只在输出中获取字段名称。查询中的引用表包含超过 50 行。请帮助解决我的问题...

<?php
$con=mysqli_connect("localhost","root","password","ayrilmana");

if (mysqli_connect_errno()){
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT txn_amount,donated_by FROM tempe_txn");

echo "<table border='1'> 
<tr>
<th>txn_amount</th>
<th>donated_by</th>
</tr>";

if($result === FALSE){
    die(mysql_error()); 
}

while($row = mysqli_fetch_array($result)){
    echo "<tr>";
    echo "<td>" . $row['txn_amount'] . "</td>";
    echo "<td>" . $row['donated_by'] . "</td>";
    echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
4

0 回答 0