我似乎不能在我的HTML上显示查询结果。它不显示任何内容。
我真的不知道该怎么做。
$qr1= mysqli_query($conn,"SELECT qr FROM `count` WHERE id=1;");
$qr2= mysqli_query($conn,"SELECT qr FROM `count` WHERE id=2;");
$qr3= mysqli_query($conn,"SELECT qr FROM `count` WHERE id=3;");
$qr4= mysqli_query($conn,"SELECT qr FROM `count` WHERE id=4;");
$qr5= mysqli_query($conn,"SELECT qr FROM `count` WHERE id=5;");
$total= $qr1 + $qr2 + $qr3 + $qr4 + $qr5;我的HTML:
<tbody>
<tr>
<th scope="row">QR1</th>
<td><?php echo $qr1 ?></td>
</tr>
<tr>
<th scope="row">QR2</th>
<td><?php echo $qr2 ?></td>
</tr>
<tr>
<th scope="row">QR3</th>
<td><?php echo $qr3 ?></td>
</tr>
<tr>
<th scope="row">QR4</th>
<td><?php echo $qr4 ?></td>
</tr>
<tr>
<th scope="row">QR5</th>
<td><?php echo $qr5 ?></td>
</tr>
</tbody>发布于 2019-10-30 09:27:06
缺少的是需要在$qr上指定列。
以下是您的代码的简短版本。
$total = 0;
$qr= mysqli_query($conn,"select qr, concat('QR', cast(id as varchar(3))) as id FROM `count` where id in (1,2,3,4,5) order by id;");
<tbody>
while ($row = mysqli_fetch_row($qr)) {
<tr>
<th scope="row">
<?php echo $row['id'] ?>
</th>
<td><?php echo $row['qr'] ?></td>
</tr>
$total = $total + $row['qr'];
}
</tbody>https://stackoverflow.com/questions/58617493
复制相似问题