-4

这是一个停车场系统。

这是我的模块之一。此代码中的错误是状态取消。

我希望状态取消将在我的系统中显示为黄色,就像状态离开一样,但仍然无法正常工作。储备,占用和黄色只有我们运作。

<?php include 'dbcon.php';
    $result = mysqli_query($con,"SELECT * FROM `zonenumber` WHERE 1");
    while ($fetch = mysqli_fetch_array($result))
    {
      $name = $fetch['name'];
      $status = $fetch['status'];
      if ($status == 'Cancel') $color = 'yellow';
      if ($status == 'Reserved') $color = 'green';
      if ($status == 'Occupied') $color = 'red';
      if ($status == 'Leave') $color = 'yellow';
      if ($color != 'yellow')
      {
        $print = "javascript:popUp('zonestatus_1.php?id=$name');";
      }
      else
      {
        $print = "javascript:alert('There is NO Information Available')";
      }
      ?>
4

3 回答 3

1

如果您可以使用 swicth 语句,则只是一个建议而不是 severl

<?php include 'dbcon.php';
    $result = mysqli_query($con,"SELECT * FROM `zonenumber` WHERE 1");
    while ($fetch = mysqli_fetch_array($result))
    {

      $name = $fetch['name'];
      $status = $fetch['status'];
      switch ($status) {
        case 'Cancel':
        case 'Leave':
          $color = 'yellow';
          break;
         case 'Reserved':
          $color = 'green';
          break;
        case 'Occupied':
          $color = 'red';
          break;
        // eventually you can manage default 
        default:
          // your code for default
          break;
      }
      if ($color != 'yellow')
      {
        $print = "javascript:popUp('zonestatus_1.php?id=$name');";
      }
      else
      {
        $print = "javascript:alert('There is NO Information Available')";
      }
    }
?>

并关闭你的while循环

于 2017-09-29T11:34:05.757 回答
0

您可以在这里简单地使用 if else 条件。并检查您的 where 条件

 <?php 
include 'dbcon.php';
$result = mysqli_query($con,"SELECT * FROM `zonenumber` WHERE 1");
while ($fetch = mysqli_fetch_array($result))
{
  $name = $fetch['name'];
  $status = $fetch['status'];
  if($status == 'Cancel')
  {
     $color = 'yellow'; 
  }
  elseif($status == 'Reserved')
  {
    $color = 'green';  
  }
  elseif($status == 'Occupied')
  {
    $color = 'red';  
  }
  elseif($status == 'Leave')
  {
    $color = 'yellow';  
  }
  else
  {
      $color = '';   // your default color
  }

  if ($color != 'yellow')
  {
    $print = "javascript:popUp('zonestatus_1.php?id=$name');";
  }
  else
  {
    $print = "javascript:alert('There is NO Information Available')";
  }
}

?>

于 2017-09-29T12:13:25.783 回答
0

希望你能很好地理解下面的内容。它是为 VBScript 设计的...

虽然有结果,但颜色是白色的。环形。如果颜色为白色(显示结果后),则颜色现在为灰色。环形。如果颜色是灰色 - 再次更改!

<%
xBg="#cccccc" 
while not rs.eof
%>   

    <tr style="background-color: <% = xBg %>">
        <td>FIELDRESULT</td>
    </tr>

<% if xBg="#cccccc" then xBg="#ffffff" else xBg="#cccccc"
rs.MoveNext 
wend %> 
于 2017-09-29T14:23:29.770 回答