php - 我的 css 在 php 代码后不起作用

标签 php html css

我的 css 在 php 代码之后不起作用。我必须在 elseif 之后重写整个 html 代码才能使格式正常工作。我已经尝试在 中插入 html 代码,但它仍然不会按照应有的方式设置样式。我的导航也不会显示。我不明白。

if(isset($_POST['sby'])){
  $value = $_POST['sby'];
  if(isset($_POST['search'])){
      if($value == 'cname'){?>
            <!doctype html>
            <head>
            <meta charset="utf-8">
            <title>Untitled Document</title>
            <link href="../../css/style.css" rel="stylesheet" type="text/css" />
            <!--[if lt IE 9]>
            <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]-->
            </head>

            <body>

            <div class="container">
            <header>
              <a href="home.php"><img src="../../img/Intellibest-EMM Logo.jpg" alt="Insert Logo Here" name="Insert_logo" width="180" height="141" id="Insert_logo" style="background-color: #C6D580; display:block;" /></a>
            </header>
            <div class="sidebar1" style="height:auto">
              <ul class="nav">
                <li><a href="../home.php">Home</a></li>
                <li><a href="../look.php">Look For</a></</li>
                <li><a href="../make.php">Make Something</a></li>
                <li><a href="../settings.php">Settings</a></li>
              </ul>
            </div>
            <table>
              <thead id="tbl">
                  <tr>
                  <td><h3>Company Name</h3></td>
                  </tr>
              </thead>
                <?php do { ?>
                <tbody id="result">
                <tr>
                <td>
                  <?php echo $row_get_cname['Company Name'];?>
                </td>
                <?php } while ($row_get_cname = mysql_fetch_assoc($get_cname)); ?>
              </tr>
              </table>
          <?php }
          else if($value == 'ename'){?>

              <table>
              <thead id="tbl">
                  <tr>
                  <td><h3>First Name</h3></td>
                  <td><h3>Last Name</h3></td>
                  <td><h3>Position</h3></td>
                  <td><h3>Company Name</h3></td>
                  </tr>
              </thead>

                  <?php do { ?>
                      <tbody  id="result">
                      <tr>
                      <td>
                          <?php echo $row_get_ename['First Name'].' '.$row_get_ename['Last Name'].'<br>'.$row_get_ename['Position'].'<br>'.$row_get_ename['client companies (pana)`.`Company Name'];?>
                      </td>
                  <?php } while ($row_get_ename = mysql_fetch_assoc($get_ename)); ?>
             </tr>
             </tbody>
             </table>
          <?php }
          else if($value == 'iname'){

              echo "<table>
               <thead id=tbl>
                  <tr>
                  <td><h3>Company Name</h3></td>
                  <td><h3>Industry</h3></td>
                  </tr>
              </thead>";
                do { 
                echo "<tbody id=result>
                <tr>
                <td>";
                echo $row_get_iname['Company Name'].'</td><td>'.$row_get_iname['Industry'];
                echo "</td>";
                 } while ($row_get_iname = mysql_fetch_assoc($get_iname));
              echo "</tr>
              </tbody>
              </table>";    
      }
      else{
          echo "Please enter a valid search quer";  
      }
  }
  else{
      echo "Please define search";
  }
}
else{
  echo "Please enter a search query";
}

最佳答案

试试这个:

 <!doctype html>
 <head>
 <meta charset="utf-8">
 <title>Untitled Document</title>
 <link href="../../css/style.css" rel="stylesheet" type="text/css" />
 <!--[if lt IE 9]>
 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 <![endif]-->
 </head>

 <body>

 <div class="container">
 <header>
  <a href="home.php"><img src="../../img/Intellibest-EMM Logo.jpg" alt="Insert Logo Here" name="Insert_logo" width="180" height="141" id="Insert_logo" style="background-color: #C6D580; display:block;" /></a>
</header>
<div class="sidebar1" style="height:auto">
  <ul class="nav">
    <li><a href="../home.php">Home</a></li>
    <li><a href="../look.php">Look For</a></</li>
    <li><a href="../make.php">Make Something</a></li>
    <li><a href="../settings.php">Settings</a></li>
  </ul>
</div>
<?php
if(isset($_POST['sby'])){
  $value = $_POST['sby'];
  if(isset($_POST['search'])){
      if($value == 'cname'){?>

这样,无论 $value 的值如何,页面的顶部都会显示。

关于php - 我的 css 在 php 代码后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13080527/

相关文章:

javascript - 替代多个“if 语句?

html - 我可以在窗口加载时一次制作一个 css 动画吗?

html - CSS 使内容DIV在内容之后自动调整大小

javascript - 如何在 href 中使用 JavaScript 变量?

php - 在 PhpSpreadsheet 中读取 Xlsx 文件

javascript - 是否可以使用 PHP 在客户端执行外部 URL 并获取 JSON 响应?

html - 如何格式化链接,使它们在所有 Angular 点中占视口(viewport)的 25%?

css - 如何在 Opera Mobile 中覆盖 'Text wrapping'

php - 我想修复响应式 WordPress 功能框

php - 从字符串到数组再到菜单