如何在bootstrap中将mysql表记录显示为导航

zdwk9cvp  于 2021-06-18  发布在  Mysql
关注(0)|答案(2)|浏览(235)

我正在使用bootstrap4和mysql,并试图将一个包含多条记录的表显示到我的列表组中,这样我就可以单击每条记录并导航到另一个页面。我要你帮忙处理密码。提前通知tnx。

cgyqldqp

cgyqldqp1#

请尝试以下代码:

<!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.php">Home</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">

              <?php 

$query = "SELECT * FROM categories LIMIT 3";
$result = mysqli_query($connection,$query);

while($row = mysqli_fetch_assoc($result)) {
   $title = $row['title'];
   $id = $row['id'];

    echo "<li><a href='category.php?category={$id}'>{$title}</a></li>";
}

?>

            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>
hxzsmxv2

hxzsmxv22#

将此数据放入或通过使其成为函数或类来调用它 <table><tr>..</tr></table> ```

相关问题