简体   繁体   中英

What am I doing wrong here with echo list and bootstrap?

I'm echoing this list from my mysql database, but I don't want bullets so I'm using bootstrap list-group-item. I feel like I'm making a really dumb mistake somewhere with my list tags but I'm not sure. I'm still getting the bullets next to my list. I'm not including all of my connecting to my database php because that's not the problem.

Here is what I have,

<div class="panel panel-info">
           <div class="panel-heading">Contents</div>
           <ul class="list-group">
            <li class="list-group-item">

                      <?php

                    basic connect to mysql database stuff here
                    }

                    $query = mysqli_query($dat, "SELECT * FROM Content ORDER BY ContentName") or die(mysqli_error($dat));
                        while($list = mysqli_fetch_array($query)){

                        echo"<li>";
                        echo"<a href = >";
                        echo $list['ContentName'];
                        echo"</a>";
                        echo "</li>";

                    }
                    mysqli_close($dat);
                    ?>

            </li>
           </ul>
         </div>

you are adding li inside another li . it should be -

<ul class="list-group">
                  <?php
                }

                $query = mysqli_query($dat, "SELECT * FROM Content ORDER BY ContentName") or die(mysqli_error($dat));
                    while($list = mysqli_fetch_array($query)){

                    echo"<li class='list-group-item'>";
                    echo"<a href = >";
                    echo $list['ContentName'];
                    echo"</a>";
                    echo "</li>";

                }
                mysqli_close($dat);
                ?>
</ul>

Use echo "<li class='list-group-item'>"; instead of <li> and remove the <li> before php code.

<div class="panel panel-info">
      <div class="panel-heading">Contents</div>
        <ul class="list-group">
           <?php

                  basic connect to mysql database stuff here
                  }

                  $query = mysqli_query($dat, "SELECT * FROM Content ORDER BY ContentName") or die(mysqli_error($dat));
                      while($list = mysqli_fetch_array($query)){

                      echo "<li class='list-group-item'>";
                      echo "<a href ='www.example.com' >";
                      echo $list['ContentName'];
                      echo "</a>";
                      echo "</li>";

                  }
                  mysqli_close($dat);
              ?>
         </ul>
    </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM