php - browser is not showing html tags in inspect element -


i have following php code. don't know what's wrong it, browser not show table in inspector.

<main class="container clear">    <?php    require 'connect.inc.php';    $query = "select * `names`";   $name = mysql_query($query);   $namelist = mysql_fetch_assoc($name);   ?>    <tr>     <td><?php echo $namelist['name']; ?></td>       <td><?php echo $namelist['designation']; ?></td>       <td><?php echo $namelist['phone']; ?></td>      <td><?php echo $namelist['email']; ?></td>    </tr>  </main> 

how can fix it?

it doesn't show table because missing <table> tag.

you'd this:

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

since have a query select * names, assume want show values, code should this:

<?php require 'connect.inc.php'; $query = "select * `names`"; $name = mysql_query($query); ?>  <main class="container clear">     <table border="1"> <!-- border see -->         <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> 

side notes:

  • that table name not best option, specially fields (name, designation, phone, email) has. try using name more suggestive.

  • oh.. , please, stop using mysql_* functions. extension deprecated in php 5.5.0, , removed in php 7.0.0. instead, mysqli or pdo_mysql extension should used. see mysql: choosing api guide , related faq more information.


Comments