Php 将两列数组打印到HTML表中
我必须在HTML表中显示以下查询:Php 将两列数组打印到HTML表中,php,html,arrays,html-table,Php,Html,Arrays,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); 在PHPMYADMIN中运行查询时,它可以完美地满足我的需要,但我不知道如何在html表上获得相同的结果 这就是phpmyadmin中的显示方式: 任何帮助都将不胜感激。
$query= "SELECT SUM(amount_pln) AS suma,country FROM fin_revenues GROUP BY country ORDER BY suma DESC";
$result = mysqli_query($mysqli,$query);
在PHPMYADMIN中运行查询时,它可以完美地满足我的需要,但我不知道如何在html表上获得相同的结果
这就是phpmyadmin中的显示方式:
任何帮助都将不胜感激。$query=“按国家顺序从财务收入组中选择金额(pln)作为suma,国家/地区suma DESC”;
$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';
$result=mysqli\u查询($mysqli,$query);
回声'
苏玛
国家>
';
while($row=mysqli\u fetch\u array($mysqli,$result))//有记录时
{
回显“$row['suma']”。$row['country']”;//回显带有查询结果的表
}
echo“$query=”按suma DESC从财务收入组中按国家顺序选择suma的金额(pln);
$result=mysqli\u查询($mysqli,$query);
呼应“sumaconcountry”;
while($row=mysqli\u fetch\u assoc($result)){
回显“$row['suma']”。$row['country']”;
}
回声“;
mysqli_免费_结果($result);
我在下面的一行中得到一个错误,似乎是因为单引号回显“$row['suma']]$row['country']”;谢谢,到目前为止,我只拿到了SUMA&country@user2952715,我已经更新了我的答案。。你得到的答案有错误吗?如果你的答案是第一个且正确的,那么这两个答案看起来很相似,而不是为什么其他人再次发布相同的答案。请投我一票赞成你的答案
$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);