我正在尝试验证从 SQL 查询中获得的结果,并检查是否返回零结果,我正在尝试回显适当的消息。然而,我正在努力做到这一点,我试图使用 if 语句但没有工作的任何想法。下面是我的代码。
<?php
$mysql_query = "SELECT ISO_id, country_name, population, gdp, gold, silver, bronze, total FROM Country WHERE ISO_id='$countryID'";
$runmysql_query=mysql_query($mysql_query);
echo "<table class = 'table' border='4' align = 'center'>
<tr class = 'title'>
<th>ISOid</th>
<th>Country Name</th>
<th>Population</th>
<th>GDP</th>
<th>Gold</th>
<th>Silver</th>
<th>Bronze</th>
<th>Total</th>
</tr>"; //title headings declared
while($row = mysql_fetch_array($runmysql_query))
{
echo "<tr>";
echo "<td class = 'results'>" . $row['ISO_id'] . "</td>";
echo "<td class = 'results'>" . $row['country_name'] . "</td>";
echo "<td class = 'results'>" . $row['population'] . "</td>";
echo "<td class = 'results'>" . $row['gdp'] . "</td>";
echo "<td class = 'results'>" . $row['gold'] . "</td>";
echo "<td class = 'results'>" . $row['silver'] . "</td>";
echo "<td class = 'results'>" . $row['bronze'] . "</td>";
echo "<td class = 'results'>" . $row['total'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>