如何使用php创建其他css选项卡

时间:2015-11-18 21:09:33

标签: php html mysql css tabs

我正在尝试添加addtional选项卡,只要将新项添加到数据库中它应该显示在网页上并显示新项而不必进入代码只需添加到数据库我试过{{ 1}}变量尝试id,但是没有用。

CODE:

$_GET

CSS代码:

<?php
$sql = "SELECT * FROM pages WHERE id = " . $_GET['id'];
$result = mysqli_query($db, $sql);
while ($pages = mysqli_fetch_assoc($result)) {
?>
<ul class="tabs">
<li>
    <input type="radio" name="tabs" id="tab1" checked />
    <a href="?id=<?php echo $pages['id']; ?>"><label for="tab1"><?php echo $pages['name']; ?></label></a>
    <div id="tab-content" class="tab-content">
      <p><?php echo $pages['content']; ?></p>
    </div>
</li>

</ul>
<?php } ?>

1 个答案:

答案 0 :(得分:0)

<?php
$id=$_GET['id'];
$sql = "SELECT * FROM pages WHERE id ='$id'";
$result = mysqli_query($db, $sql);
while ($pages = mysqli_fetch_assoc($result)) {
?>
<ul class="tabs">
<li>
    <input type="radio" name="tabs" id="tab1" checked />
    <a href="?id=<?php echo $pages['id']; ?>"><label for="tab1"><?php echo $pages['name']; ?></label></a>
    <div id="tab-content" class="tab-content">
      <p><?php echo $pages['content']; ?></p>
    </div>
</li>

</ul>
<?php } ?>

尝试此代码不确定但请尝试..