带有INNER JOIN查询的PHP和Mysql-仅看到标题,没有数据

export const getPackageScenariosactionSuccess = createaction(
  '[Package Scenario] Success get package scenarios',props<{ packageScenarios: PackageScenario[];} >()
);

<?php $conn = mysqli_connect("localhost","root","","konkal"); $result = mysqli_query($conn," SELECT * FROM tb_hitung JOIN tb_makanan ON tb_hitung.id = tb_makanan.id WHERE ket_waktu = 'pagi' "); while( $row = mysqli_fetch_assoc($result)); ?> <tr> <th>Gambar Makanan</th> <th>Nama Makanan</th> <th>Jenis Makanan</th> <th>Waktu Makan</th> <th>Jumlah Kalori</th> </tr> <tr> <td><img src="<?php echo $row['gambar'] ?>" width="100"></td> <td><?php echo $row["nama"] ?></td> <td><?php echo $row["kategori"] ?></td> <td><?php echo $row["ket_waktu"] ?></td> <td><?php echo $row["kkal"]," kkal" ?></td> </tr>

tb_hitung

id kkal ket_waktu 12 360 kkal pagi 2 810 kkal malam 24 108 kkal siang 9 286 kkal pagi

tb_makanan

我希望输出显示查询过滤器ket_waktu ='pagi'的结果。我只看到表格的第一行(标题)。

zmc9556 回答:带有INNER JOIN查询的PHP和Mysql-仅看到标题,没有数据

PART 1

连接点> df reported_time Date Time 1 2019-09-03 07:07 2019-09-03 07:07 2 2019-09-24 08:17 2019-09-24 08:17 3 2019-09-03 07:27 2019-09-03 07:27 4 2019-10-20 08:02 2019-10-20 08:02 5 2019-05-02 14:15 2019-05-02 14:15 6 2019-05-02 14:49 2019-05-02 14:49 7 2019-05-02 20:22 2019-05-02 20:22 8 2019-10-20 20:42 2019-10-20 20:42 9 2019-09-18 15:19 2019-09-18 15:19 10 2019-10-09 09:11 2019-10-09 09:11 11 2019-10-21 08:37 2019-10-21 08:37 12 2019-05-02 08:57 2019-05-02 08:57 13 2019-05-02 12:35 2019-05-02 12:35 14 2019-05-02 22:46 2019-05-02 22:46 仅创建一个“匹配”。 例如:tb_hitung ID 12 应该与tb_makanan ID 12 相匹配。但是tb_makanan的ID为 12 的零行(无匹配项)。

只有一个匹配项...位于tb_hitung.id = tb_makanan.idhitung 2 ...上,但是 where子句过滤了“ pagi”的名称。因此,鉴于此数据,查询将具有“零行”

PART 2

正如@barmar所提到的...分号结束了makanan 2循环而没有循环 ,并且标题行不应该出现在循环中。为此,我将通过一个适当的循环示例来阐明所有这些闲聊:

while
本文链接:https://www.f2er.com/3164789.html

大家都在问