简体   繁体   English

如何在mysqli表列中一个接一个地列出所有相关数据

[英]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.

相关问题 PHP,HTML和MySqli-如何在一个表行中显示特定列的所有数据 - PHP, HTML and MySqli - how to show all data from specific column in one table row 如何在PHP Codeigniter中从一个表中获取特定列,并从另一表中获取所有其他数据 - How to get specific column from one table and all other data from other table in php codeigniter 查询数据库后如何从数组调用特定的行和列数据…(mysqli php) - How do i call specific row and column data from an array after querying a database… (mysqli php) MySQL查询从数据库表中的所有字符串中查找特定区域数据并列出所有相关的标题 - MySQL query to find out specific region data from all strings in database table and list all related banners 如何使用分组依据,但将所有其他值保留在列中(在mysqli中) - How to use Group By, but keep all other values in the column (in mysqli) 我如何从一个表中提取数据,并将其插入到另一个表中的列? - How do i pull data from one table and insert it into a column in another table? 如何使用Eloquent和Laravel 4返回表中的所有列? - How do I return all of one column in a table using Eloquent and Laravel 4? 如何从一个表中选择与表中的列值相匹配的数据? - How do I select data from one table where column values from that table match the conatenated column values of another table? 如何通过php从mysql表中获取所有数据,并打印出每个单元格的内容? - How do I get all data from a mysql table via php, and print out the contents of every cell? 如何在php / html中一个接一个地回显多个表数据 - How to echo multiple table data one after the other in php/html
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM