dongzhi9192 2018-08-08 06:46
浏览 70
已采纳

正确的语法在<td>中使用条件检查? [关闭]

This code works fine but i dont want show btnvalue which is zero and one istead of that i want show Log-In Log-out with checking btnvalue which is zero and one. Help me with the correct syntax of checking value or if/else condtion inside td tag.

 <?php  

 if(isset($_POST["from_date"] , $_POST["to_date"]))  
 {

  $connect = mysqli_connect("localhost", "root", "root", "attendance");  
  $output = '';  
  $query ="SELECT * FROM logintime WHERE date BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."'  UNION SELECT * FROM logouttime WHERE date BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."'
    ";
  $result = mysqli_query($connect, $query);  
  $output .= '  
       <table class="table table-bordered">  
            <tr>  
                <th>EMP-ID</th>
                <th>STATUS</th>
                <th>TIME</th>
                <th>DATE</th>
                <th>DAILY JOB</th>
            </tr> 
  ';


  if(mysqli_num_rows($result)>0)
  {
       while($row = mysqli_fetch_assoc($result))  
       {  
            $output .= '  
                 <tr>  
                      <td>'. $row["techid"] .'</td>  
                      <td>'. $row["btnvalue"].'</td>  
                      <td>'. $row["time"] .'</td>  
                      <td>'. $row["date"] .'</td>  
                      <td>'. $row["comment"] .'</td>  
                 </tr>  
            ';  
       }  
    }
  else  
  {  
       $output .= '  
            <tr>  
                 <td colspan="5">No Attendance Found</td>  
            </tr>  
       ';  
  }  
  $output .= '</table>';  
  echo $output;  
 }
 ?>
  • 写回答

2条回答 默认 最新

  • duanmo7075 2018-08-08 07:11
    关注

    The following will show Log-in or Log-out based on btnvalue:

    <?php  
    
     if(isset($_POST["from_date"] , $_POST["to_date"]))  
     {
    
      $connect = mysqli_connect("localhost", "root", "root", "attendance");  
      $output = '';  
      $query ="SELECT * FROM logintime WHERE date BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."'  UNION SELECT * FROM logouttime WHERE date BETWEEN '".$_POST["from_date"]."' AND '".$_POST["to_date"]."'
        ";
      $result = mysqli_query($connect, $query);  
      $output .= '  
           <table class="table table-bordered">  
                <tr>  
                    <th>EMP-ID</th>
                    <th>STATUS</th>
                    <th>TIME</th>
                    <th>DATE</th>
                    <th>DAILY JOB</th>
                </tr> 
      ';
    
    
      if(mysqli_num_rows($result)>0)
      {
           while($row = mysqli_fetch_assoc($result))  
           {  
                $output .= '  
                     <tr>  
                          <td>'. $row["techid"] .'</td>  
                          <td>'.(($row["btnvalue"]=='0') ? 'Log-in':'Log-out').'</td>  
                          <td>'. $row["time"] .'</td>  
                          <td>'. $row["date"] .'</td>  
                          <td>'. $row["comment"] .'</td>  
                     </tr>  
                ';  
           }  
        }
      else  
      {  
           $output .= '  
                <tr>  
                     <td colspan="5">No Attendance Found</td>  
                </tr>  
           ';  
      }  
      $output .= '</table>';  
      echo $output;  
     }
     ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度