duanlu0075 2017-09-27 09:35
浏览 47

如何在文章页面中设置表格样式?

I imported a database in phpMyAdmin that contains articles. I want it to be regulated, to automatically post the image, title, and contents in the articles page. And to direct it to another page when clicked.

But when rendering the articles page, the second row has two columns offset. I think it's the content of the first 2 articles that's making the problem since I did another tables with few contents in it then it renders exactly the way I want(a row that contains 3 articles an no offset below it). I'm a newbie here, feel free to suggest if there's a better way. I genuinely appreciate it. Thank you!

<div class="blogs-2" id="blogs-2">
  <div class="container">
    <div class="row">
      <div class="col-md-10">
        <div class="row">
          <?php
                    $sql = "SELECT * FROM news LIMIT 20";
                    $result= $DBcon->query($sql);
                    if ($result->num_rows > 0) {
                        while ($row = $result->fetch_assoc()) {
                    ?>
            <div class="col-md-4" style="margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0; ">
              <div class="card card-plain card-blog" style="max-height:300px;float:left;">
                <div class="card-image">
                  <a href="../news/article.php?id=<?php echo $row['id']; ?>">
                                    <img class="img img-raised" src="<?php header("Content-type: image/png"); echo $row['featured_image'] ?>" style="max-height:300px;" />
                                </a>
                </div>
                <div class="card-content">
                  <h4 class="card-title">
                    <a href="../news/article.php?id=<?php echo $row['id']; ?>">
                      <?php echo $row['title']; ?>
                    </a>
                  </h4>
                  <p class="card-description" style="overflow: hidden;display: -webkit-box;-webkit-line-clamp: 3;-webkit-box-orient: vertical;">
                    <?php echo $row['content']; ?>
                  </p>
                  <p class="card-description">
                    <a href="../news/article.php?id=<?php echo $row['id']; ?>"> Read More </a>
                  </p>
                </div>
              </div>
            </div>

            <?php
                        }
                    }
                    else {
                        echo "<p>No News Articles to Display</p>";
                    }
                    ?>
        </div>
      </div>
      <div class="col-md-2">
        <h4 class="title">Recent News</h4>
        <ul>
          <?php
                    $sql = "SELECT * FROM news LIMIT 5";
                    $result= $DBcon->query($sql);
                    if ($result->num_rows > 0) {
                        while ($row = $result->fetch_assoc()) {
                            echo "<li style='list-style:none;color:black;padding-top:5px;padding-bottom:5px;'><a href='../news/article.php?id={$row['id']}'>" .$row['title']. "</a></li>";
                        }
                    }
                    else {
                        echo "<li style='list-style:none;'>No Recent News</li>";
                    }
                    ?>
        </ul>
      </div>
    </div><!--row-->
  </div><!--container-->
</div><!--blogs-->

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题