我正在使用引导程序4和mysql,并试图将包含多个记录的表显示到列表组中,这样我应该能够单击每个记录并导航到另一页。我希望您能提供有关代码的帮助。 提前Tnx。
答案 0 :(得分:0)
尝试以下代码:
<!-- 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>
答案 1 :(得分:0)
放置此数据或通过使其成为<table><tr>..</tr></table>
<?php
$query = "SELECT * FROM data";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result)) {
$title = $row['title'];
$link = $row['link'];
echo "<td><a href='category.php?data={$link}'>{$title}</a></td>";
}
?>