[英]How do i list out all related data in mysqli table column one after the other
How do i list out all related data in mysqli database one after the other?如何一个接一个地列出mysqli数据库中的所有相关数据? I tried these code below.
我在下面尝试了这些代码。 It outputs unknown result:
它输出未知的结果:
<?php
include_once "init.php";
$sqli = mysqli_query($conn, "SELECT * FROM books WHERE book='1905515'");
$productCount = mysqli_num_rows($sqli);
if ($productCount > 0) {
while($fow = mysqli_fetch_array($sqli)){
foreach ($fow as $item) {
$id = $item['item_name'];
}
}
}
echo '' . $id . '';
?>
when you call echo '' . $id . '';
当你打电话给
echo '' . $id . '';
echo '' . $id . '';
$id doesn't exist anymore because $id exists only in foreach scope. $id 不再存在,因为 $id 仅存在于 foreach 范围内。
Try this :尝试这个 :
include_once "init.php";
$sqli = mysqli_query($conn, "SELECT * FROM books WHERE book='1905515'");
$productCount = mysqli_num_rows($sqli);
if ($productCount > 0) {
while($fow = mysqli_fetch_array($sqli)){
echo '' . $fow['item_name'] . '';
}
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.