Jump to content

lovephp

Members
  • Posts

    530
  • Joined

  • Last visited

Everything posted by lovephp

  1. So how much bandwidth etc phpfreaks requires a month? Its on a shared or some vps hosting plan? Curious
  2. What is true false doing in your if else statement? How is the if statement suppose to know if status[1] is less than true hahaha wtf man assign some value to the true like $true = 1; If($status[1] < $true){ echo 'bla bla'; } Or something this it has to be $status[1] = 'true'; If($status[1] == 'true'){ echo 'bla bla'; }
  3. Post the codes don't go uploading files in bulk. And what have you tried so far?
  4. Install cctv cams to your redirect.php file. Jokes hehe,
  5. You are talking about company and the codes are for country state, look for a 3tire dropdown that will solve your issue.
  6. sorry missed out to remove the time_to_sec
  7. Anyway what exactly seems to be wrong in this code that i don't get the exact count for total hours?
  8. Yes yes i agree infact after all you guys told me i have started using pdo but his is an very old script too much time it will take to convert and moreover this is not for online purpose
  9. Its just an old offline script i do use prepared statements on my new script
  10. so this is calculating time differences but something about the total_time is not ok it wont display correct number of total hours <?php $usr = $_REQUEST['uname']; $yr = $_REQUEST['year']; $mn = $_REQUEST['month']; $chk = "$yr-$mn"; $query = "SELECT hours_id, member_id, member_name, team, time_in, time_out, SEC_TO_TIME(TIME_TO_SEC(TIMEDIFF(time_out, time_in))) AS totalhours FROM hours where time_in LIKE '%".$chk."%' and member_id = '".$usr."'"; $result = mysql_query($query)or die(mysql_error()); $rowNo = 1; $total_time="00:00:00"; while($row = mysql_fetch_assoc($result)){ $time = $row['totalhours']; $secs = strtotime($time)-strtotime("00:00:00"); $total_time = date("H:i:s",strtotime($total_time)+$secs); echo "<tr align='left'>"; echo"<td><font color='white'>" .$rowNo++."</font></td>"; echo"<td><font color='white'>" .$row['member_name']."</font></td>"; echo"<td class='edit_td'><font color='white'>" .date('Y-M-d - h:i:s a ', strtotime($row['time_in']))."</font></td>"; if($row['time_in'] == $row['time_out']){ echo"<td><font color='green'>STILL LOGGED IN</font></td>"; }else{ echo"<td class='edit_td'><font color='white'>" .date('Y-M-d - h:i:s a ', strtotime($row['time_out']))."</font></td>"; } if($row['time_out'] == '0000-00-00 00:00:00'){ echo"<td><font color='white'></font></td>"; }else{ echo"<td><font color='white'>" .$time." Hrs</font></td>"; echo"<td><font color='white'><a href ='edit-logins.php?id=".$row['hours_id']."&mid=".$row['member_id']."' target='_blank'><img src='images/edit.png' alt='Edit' height='16' width='16' title='Edit'></a> | <a href='javascript:delete_id(".$row['hours_id'].")'><img src='images/x.gif' alt='Delete' height='16' width='16' title='Delete'></a></font></td>"; } echo "</tr>"; } ?> </table> <?php echo '<p align="right"><font size="4" color="black">Sub Total:</font> '.$total_time.' Hrs </p>'; ?>// This line where i wish to display the all total count of time attached image has the result how it is displaying. any idea what could be wrong? my check was to select from db where time_in like 2016-07 and user id 2
  11. ok its solved. thank you both appreciate your help, cheers
  12. thanks and how to get the total for both the rows? 21:30:00 hrs?
  13. finally happening what i was looking for $query = "select member_id, member_name, team, time_in, time_out, sec_to_time(unix_timestamp(time_out) - unix_timestamp(time_in)) AS totalhours from hours WHERE member_id ='7'"; $result = mysql_query($query)or die(mysql_error()); $rowNo = 1; //Increment Row Number while($row = mysql_fetch_assoc($result)){ $time = $row['totalhours']; echo "<tr align='left'>"; echo"<td><font color='white'>" .$rowNo++."</font>.</td>"; echo"<td><font color='white'>" .$row['member_name']."</font>.</td>"; echo"<td><font color='white'>" .date('Y-M-d - h:i:s a ', strtotime($row['time_in']))."</font>.</td>"; echo"<td><font color='white'>" .date('Y-M-d - h:i:s a ', strtotime($row['time_out']))."</font>.</td>"; echo"<td><font color='white'>" .$time." Hrs</font>.</td>"; echo "</tr>"; } the output is on the image. now how to i get total count of all rows as in total of all time_in and time_out?
  14. fixed ) was missing but still it wont update the max hours_id of a user
  15. what is wrong in this query $dt = date("Y-m-d h:i:s"); $sql = "UPDATE hours SET time_out = '".$dt."' WHERE member_id IN (SELECT MAX(hours_id) FROM hours WHERE member_id = '".$_SESSION['MEMBER_ID']."'"; mysql_query($sql) or die(mysql_error()); that is gives me this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  16. i got issues updating clock out time, currently im trying this i added this to my logout.php but it just wont update the time_out field $dt = date("Y-m-d h:i:s"); mysql_query("UPDATE hours SET time_out = '".$dt."' WHERE member_id IN (SELECT MAX(hours_id) FROM hours WHERE member_id = '".$_SESSION['MEMBER_ID']."'"); but if i do insert it does ill show you my schema -- -- Table structure for table `hours` -- CREATE TABLE IF NOT EXISTS `hours` ( `hours_id` int(11) NOT NULL AUTO_INCREMENT, `member_id` int(11) NOT NULL, `member_name` varchar(32) NOT NULL, `team` varchar(32) NOT NULL, `time_in` datetime NOT NULL, `time_out` datetime DEFAULT NULL, `dated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`hours_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `hours` -- what could i be doing wrong now?
  17. thanks you @Barand you are right about the teams i should have a separate table for that and yes i get now the time work table should be appreciate you both for the time. let me give this a try and i will get back.
  18. thanks mate you are actually right this way is easier but with 2 saperate tables i was being able to avoid multiple entires for same date till user dont click logout it wont optout
  19. im just storing it on the 2 that would be a better idea i guess but now the issue is fetching the data
  20. i created this two tables CREATE TABLE IF NOT EXISTS `timein` ( `id` int(11) NOT NULL AUTO_INCREMENT, `member_id` int(11) NOT NULL, `member_name` varchar(32) NOT NULL, `team` varchar(32) NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `timeout` ( `id` int(11) NOT NULL AUTO_INCREMENT, `member_id` int(11) NOT NULL, `member_name` varchar(32) NOT NULL, `team` varchar(32) NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; what would be the way to display daily or monthly total hours of particulat team? i know i got to join tables but i am not sure how to do that i tried this but no results $mnt = date("2016-07-30"); SELECT * FROM timein LEFT JOIN timeout WHERE timein.time LIKE '%".$mnt."%' AND = timeout.time LIKE '%".$mnt."%'AND team = 'TeamA'
  21. i get you, thanks
  22. th is is really confusing with the night shift thing you are right if a employee has to leave early and also with login and logout supposing employee gets logout for some reason then also there will be a conflict i guess manually enter the hours like 8 for a day next is say 5 hours the other day would that be a better idea? then calculating the total for a month also would not be an issue right?
  23. Yes i did try datetime fields for time in and time out
  24. Thanks but you know by the time its logoff time its a different date already and how would i get total for the month if last day of the month work ends at the first day of Next month?. Is there also a way to assign a particular id to all those rows along while loop? Autoincrement adds different ids for all todays attendance its hard to fetch all if they don't have a similar id.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.