浏览器没有在inspect元素中显示html标签

时间:2016-07-21 20:44:42

标签: php

我有以下PHP代码。我不知道它有什么问题,但浏览器没有在检查员中显示该表。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div align="center" id="feedTxt">

    <div class="some">
        <h1>title 1</h1>
        <br>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
    </div>



    <div class="some">
        <h1>title 2</h1>
        <br>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
    </div>


    <div class="some">
        <h1>title 3</h1>
        <br>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
    </div>


    <div class="some">
        <h1>title 4</h1>
        <br>
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
            with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
    </div>


</div>

我该如何解决?

1 个答案:

答案 0 :(得分:1)

它没有显示表格,因为您缺少<table>标记。

你这样做:

    .. code ..
    ?>
    <table>
        <tr>
            .. code ..
        </tr>
    </table>
</main>

由于您有SELECT * FROM names之类的查询,我假设您要显示所有值,因此您的代码应如下所示:

<?php
require 'connect.inc.php';
$query = "SELECT * FROM `names`";
$name = mysql_query($query);
?>

<main class="container clear">
    <table border="1"> <!-- border just for you to see it -->
        <tr>
            <th>Name</th>
            <th>Designation</th>
            <th>Phone</th>
            <th>Email</th>
        </tr>
        <?php
        while($namelist = mysql_fetch_assoc($name);
            echo '<tr>';
                echo '<td>' . $namelist['name'] . '</td>';
                echo '<td>' . $namelist['designation'] . '</td>';
                echo '<td>' . $namelist['phone'] . '</td>';
                echo '<td>' . $namelist['email'] . '</td>';
            echo '</tr>';
        }
        ?>
    </table>
</main>

旁注:

  • 该表名可能不是最佳选择,特别适用于它所拥有的字段(namedesignationphoneemail。尝试使用更具暗示性的名称。

  • 哦......请,stop using mysql_*函数。此扩展在PHP 5.5.0中已弃用,并且已在PHP 7.0.0中删除。相反,应使用MySQLiPDO_MySQL扩展名。有关详细信息,另请参阅MySQL: choosing an API指南和related FAQ