doulan9419 2017-02-01 06:39
浏览 278

无法在php中使用css样式表

I am unable to style the table in css even though i have insert style for the tables.

<style>
table, th, td 
{
border: 1px solid black;
}
</style>

The above is a simple style for the codes

<div class="container">
    <table class="u-full-width">
    <?php


      $result=mysqli_query($connection,"SELECT * FROM register");

  }
  else
  {
      $result=mysqli_query($connection,"SELECT * FROM Persons WHERE username LIKE '".$Search."%'");
  }
  echo "<table border='1'>
  <tr>
  <th>username</th>
  <th>password</th>
  <th>Name</th>
  <th>gender</th>
  <th>age</th>
  <th>Contact</th>
  <th>address</th>
  <th>email</th>
  <th>occupation</th>     
  </tr>";

    while($row=mysqli_fetch_array($result))
  {
      echo "<tr>";
      echo "<td>" . $row['Username'] . "</td>"; 
      echo "<td>" . $row['password'] . "</td>";
      echo "<td>" . $row['Name'] . "</td> ";
      echo "<td>" . $row['gender'] . "</td>";
      echo "<td>" . $row['age'] . "</td> ";
      echo "<td>" . $row['contact'] . "</td>";
      echo "<td>" . $row['address'] . "</td>";
      echo "<td>" . $row['email'] . "</td>";
      echo "<td>" . $row['occupation'] . "</td>";
      echo "</tr>";
  }
  echo"</table>";
  mysqli_close($connection);
  ?>
     </div>
     </table>

The above is for displaying the tables. May i know what i can do so that it displays the table with the css. Thanks.

  • 写回答

2条回答

  • dongwen7283 2017-02-01 06:47
    关注

    Its because your inserting the table dynamically with php.

    try this

    <div class="container">
    <table class="u-full-width" border='1'>
    <?php
    
    if () {//note code is incomplete, might be copy pasting issue
      $result=mysqli_query($connection,"SELECT * FROM register");
    
    }
    else
    {
      $result=mysqli_query($connection,"SELECT * FROM Persons WHERE username LIKE '".$Search."%'");
    }
    ?>
    
    <tr>
    <th>username</th>
    <th>password</th>
    <th>Name</th>
    <th>gender</th>
    <th>age</th>
    <th>Contact</th>
    <th>address</th>
    <th>email</th>
    <th>occupation</th>     
    </tr>
    
    <?php
    while($row=mysqli_fetch_array($result))
    {
      echo "<tr>";
      echo "<td>" . $row['Username'] . "</td>"; 
      echo "<td>" . $row['password'] . "</td>";
      echo "<td>" . $row['Name'] . "</td> ";
      echo "<td>" . $row['gender'] . "</td>";
      echo "<td>" . $row['age'] . "</td> ";
      echo "<td>" . $row['contact'] . "</td>";
      echo "<td>" . $row['address'] . "</td>";
      echo "<td>" . $row['email'] . "</td>";
      echo "<td>" . $row['occupation'] . "</td>";
      echo "</tr>";
    }
    mysqli_close($connection);
    ?>
    
    </table>
     </div>
     </table>
    

    This way your table code is loaded with the page, and any information from the database is dynamically loaded

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据