[英]Print two columns array into HTML table
I have the following Query that I have to display in a HTML table: 我必须在HTML表中显示以下查询:
$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC";
$result = mysqli_query($mysqli,$query);
When running the query in PHPMYADMIN, it works perfectly as I need but I can't figure out how to get the same result on a html table. 在PHPMYADMIN中运行查询时,它可以按我的需要完美运行,但是我不知道如何在html表上获得相同的结果。
That's how is displayed in phpmyadmin: 这就是在phpmyadmin中显示的方式:
Any help will be much appreciated. 任何帮助都感激不尽。
$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC";
$result = mysqli_query($mysqli,$query);
echo '<table>
<tr>
<td>Suma</td>
<td>Country></td>
</tr>';
while($row=mysqli_fetch_array($mysqli,$result)) // while there are records
{
echo "<tr><td>".$row['suma']."</td><td>".$row['country']."</td></tr>"; // echo the table with query results
}
echo '</table';
$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC";
$result = mysqli_query($mysqli,$query);
echo "<table><tr><td>SUMA</td><td>country</td></tr>";
while($row = mysqli_fetch_assoc($result)){
echo "<tr><td>".$row['suma']."</td><td>".$row['country']."</td></tr>";
}
echo "</table>";
mysqli_free_result($result);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.