静态页面可以工作,但是当放入PHP时,CSS没有正确呈现

时间:2017-12-25 06:00:46

标签: php html css

我在HTML文件中有以下代码。这会创建一个样式列表。

<style>
/* LIST #8 */
#list8 {  }
#list8 ul { list-style:none; }
#list8 ul li { font-family:Georgia,serif,Times; font-size:18px; }
#list8 ul li a { display:block; width:300px; height:28px; background-color:#333; border-left:5px solid #222; border-right:5px solid #222; padding-left:10px;
  text-decoration:none; color:#bfe1f1; }
#list8 ul li a:hover {  -moz-transform:rotate(-5deg); -moz-box-shadow:10px 10px 20px #000000;
  -webkit-transform:rotate(-5deg); -webkit-box-shadow:10px 10px 20px #000000;
  transform:rotate(-5deg); box-shadow:10px 10px 20px #000000; }
</style>
<div id="list8">
   <ul>
      <li><a href="#">9th Fall 2017</a></li>
      <li><a href="#">10th Spring 2018</a></li>
   </ul>
</div>

这是HTML文件呈现的方式。

enter image description here

我有以下PHP文件。

<?php
$link = mysqli_connect("localhost", "root", "password", "Booking_Databse");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$query = "SELECT SemesterName FROM Semester_tbl";

if ($result = mysqli_query($link, $query)) {
?>
<style>
/* LIST #8 */
#list8 {  }
#list8 ul { list-style:none; }
#list8 ul li { font-family:Georgia,serif,Times; font-size:18px; }
#list8 ul li a { display:block; width:300px; height:28px; background-color:#333; border-left:5px solid #222; border-right:5px solid #222; padding-left:10px;
  text-decoration:none; color:#bfe1f1; }
#list8 ul li a:hover {  -moz-transform:rotate(-5deg); -moz-box-shadow:10px 10px 20px #000000;
  -webkit-transform:rotate(-5deg); -webkit-box-shadow:10px 10px 20px #000000;
  transform:rotate(-5deg); box-shadow:10px 10px 20px #000000; }
</style>
<div id="list8">
   <ul>
  </ul><?php
    /* fetch associative array */
    while ($row = mysqli_fetch_row($result)) {
      echo '<li><a href="#">' . $row[0] . '</a></li>';

    }
  ?>
     </ul>
</div>
  <?php

    /* free result set */
    mysqli_free_result($result);
}

/* close connection */
mysqli_close($link);
?>

这是PHP文件呈现的方式:

enter image description here

我希望PHP文件像HTML文件一样呈现。我不知道我做错了什么。

3 个答案:

答案 0 :(得分:4)

在执行循环之前关闭<label>Enter the number of seconds for the timer <input id='initial' type="text"> </label> <br> Press the button to start the timer <br> <button id="start_timer">Timer</button> ...

请参阅:

<ul>

更改为:

<div id="list8">
   <ul>
  </ul><?php
    /* fetch associative array */
    while ($row = mysqli_fetch_row($result)) {
      echo '<li><a href="#">' . $row[0] . '</a></li>';

    }
  ?>
     </ul>
</div>

答案 1 :(得分:3)

在循环前关闭[workspace] $ /bin/bash +x /tmp/hudson2881472966362898766.sh /tmp/hudson2881472966362898766.sh: line 3: date: command not found /tmp/hudson2881472966362898766.sh: line 3: cut: command not found /tmp/hudson2881472966362898766.sh: line 8: mysql: command not found /tmp/hudson2881472966362898766.sh: line 16: date: command not found /tmp/hudson2881472966362898766.sh: line 16: cut: command not found /tmp/hudson2881472966362898766.sh: line 17: -: syntax error: operand expected (error token is "-") Build step 'Execute shell' marked build as failure

</ul>

答案 2 :(得分:3)

<div id="list8">
   <ul>
  <?php
    /* fetch associative array */
    while ($row = mysqli_fetch_row($result)) {
      echo '<li><a href="#">' . $row[0] . '</a></li>';

    }
  ?>
     </ul>
</div>