PHP将在一行中显示所有记录

问题描述 投票:-1回答:1

我正在写一个论坛,我的PHP代码在一个简单的行上显示所选列的所有记录。

码:

<td bgcolor="#FAB1CA">
<?php
$link = mysqli_connect("xxxx", "xxx", "xxxx", "xxxxxx");

if ($link === false) {
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

if (isset($_SESSION['logged'])) {
    $sql = "Select ID from forum_question ORDER by id DESC";
    $result = mysqli_query($link, $sql);
    while ($row = mysqli_fetch_assoc($result)) {
        $show = $row['ID'];
            print_r($show);
    }
}

mysqli_close($link);
?>        
</td>
php html
1个回答
0
投票
<td bgcolor="#FAB1CA">
    <?php
        $link = mysqli_connect("xxxx", "xxx", "xxxx", "xxxxxx");
        if($link === false){
            die("ERROR: Could not connect. " . mysqli_connect_error());
        }
        if(isset($_SESSION['logged'])){
        $sql= "Select ID from forum_question ORDER by id DESC";
        $result = mysqli_query($link, $sql);
        while($row = mysqli_fetch_assoc($result)){
            $show = $row['ID'];
            print_r($show);
            echo"<br />";
        }
       }
     mysqli_close($link);
   ?> 
 </td>

请回复“br”标签。希望你的问题能得到解决。

© www.soinside.com 2019 - 2024. All rights reserved.