showing user detail who has login

问题: I am writing a attendance page for internal use. now I encounter a problem which is only shows user detail who has login. could anyone improve the following script? <?...

问题:

I am writing a attendance page for internal use. now I encounter a problem which is only shows user detail who has login. could anyone improve the following script?

<?php

$query_RecBoards ="SELECT * FROM `attend` WHERE 
`m_username`='".$_SESSION["loginMember"]."' ORDER BY `m_time` DESC";
$RecBoards = mysql_query($query_RecBoards); 
$row_RecBoards = mysql_fetch_assoc($RecBoards);

$qry= "SELECT m_name, m_day, time_in, time_out, SEC_TO_TIME(
     CASE WHEN total_sec - 32400 > 0 
          THEN total_sec - 32400 
          ELSE 0 END) overtime,  
   SEC_TO_TIME(
     CASE WHEN total_sec - 32400 < 0 
          THEN 32400 - total_sec 
          ELSE 0 END) shorttime
  FROM
(
  SELECT m_name, m_day, time_in, time_out,
         TIME_TO_SEC(TIMEDIFF(COALESCE(time_out, '17:30:00'),
                          COALESCE(time_in, '08:30:00'))) total_sec
    FROM
  (
   SELECT m_name, m_day, 
       MIN(CASE WHEN m_duty = 'Punchin' THEN m_time END) time_in,
       MIN(CASE WHEN m_duty = 'Punchout' THEN m_time END) time_out
      FROM attend
     GROUP BY m_name, m_day
  ) a
) b";
$result=mysql_query($qry);
?>

Henrik


回答1:

Thanks for your advice, because I am using old version of PHP, that's why I am using old extension.

Finally, I figured out how to display the users who have logged in, but another question is how to display the data every month? any advice?

The improved part of code as following,

 SELECT m_name, m_day, 
         MIN(CASE WHEN m_duty = 'punchin' THEN m_time END) time_in,
         MIN(CASE WHEN m_duty = 'punchout' THEN m_time END) time_out
    FROM attend WHERE m_username='".$_SESSION["loginMember"]."'
   GROUP BY m_name, m_day
    )a  LIMIT 0,7

Thanks Henrik

  • 发表于 2018-07-08 10:02
  • 阅读 ( 235 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除