我试图从同一个数据库循环2个不同的表并同时显示它。我的问题是,你可以在一个while语句中循环2个不同的行吗?
<?php
$sql = "SELECT remaining from budget";
$result = mysqli_query($con,$sql);
$sql2 = "SELECT SUM(cost) as costTotal from project";
$result2 = mysqli_query($con,$sql2);
while($row = mysqli_fetch_array($result) && $row2 = mysqli_fetch_array($result2)){?>
<span id='remain'><?php echo "$row2[costTotal]"; ?></span>
<span id='text'> <?php echo "$row[remaining]"; ?></span>
<?php } ?>