Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
静态页面可以工作,但是当放入PHP时,CSS不能正确呈现_Php_Html_Css - Fatal编程技术网

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

静态页面可以工作,但是当放入PHP时,CSS不能正确呈现,php,html,css,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; borde

我在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文件的呈现方式

我有以下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文件的呈现方式:

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

在执行循环之前,请关闭您的

见:

改为:

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

    }
  ?>
     </ul>
</div>
在循环开始之前,先关闭循环

</ul><?php // <-------------------------------  This </ul> shouldn't be here
/* fetch associative array */
while ($row = mysqli_fetch_row($result)) {
  echo '<li><a href="#">' . $row[0] . '</a></li>';

}
?>
 </ul>
</ul><?php // <-------------------------------  This </ul> shouldn't be here
/* fetch associative array */
while ($row = mysqli_fetch_row($result)) {
  echo '<li><a href="#">' . $row[0] . '</a></li>';

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

    }
  ?>
     </ul>
</div>