-4
我試圖給我用PHP生成的表分配一個ID,但它一直返回一個錯誤。這是迄今爲止工作正常的完整代碼。我只需要在表格中添加一個'id',這樣我就可以在相關表格中應用css樣式PHP中的表ID
<?php
$con=mysqli_connect("localhost","<un>","<pw>","monitor");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM presnationalresults ORDER BY Percentage DESC");
echo "<table border='1'>
<tr>
<th>President</th>
<th>Party</th>
<th>Votes</th>
<th>Percentage</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['PresidentName'] . "</td>";
echo "<td>" . $row['PartyCode'] . "</td>";
echo "<td>" . $row['Votes'] . "</td>";
echo "<td>" . $row['Percentage'] . "</td>";
}
echo "</table>";
mysqli_close($con);
任何幫助?也許我會以錯誤的方式去談論它?
是我們應該去猜測確切的錯誤? – zerkms
那裏有更多的MySQL代碼? –
爲什麼要用echo來輸出靜態HTML?你所做的只是讓你的報價變得很難。 – Phil