egiblock Posted January 2, 2013 Share Posted January 2, 2013 hello, I have an employee in / out board that someone else coded, and I am trying to generate a report from a table of data. I have the logic in my head, just not sure how to get it down to work correctly. It's currently written in PHP with a mysql database backend. For example. Data Table: ---------------------------------------------------------------- ID - NAME - DIRECTION - DATED - DATET ---------------------------------------------------------------- 37 Employee1 2 2012-09-09 20:53:25 37 Employee1 1 2012-09-09 20:53:33 39 Employee2 2 2012-09-10 07:58:51 37 Employee1 2 2012-09-10 09:08:56 39 Employee2 1 2012-09-10 17:03:29 37 Employee1 1 2012-09-10 17:10:47 37 Employee1 2 2012-09-11 08:14:14 39 Employee2 2 2012-09-11 08:14:22 37 Employee1 1 2012-09-11 12:51:59 39 Employee2 1 2012-09-11 12:53:12 37 Employee1 2 2012-09-11 14:44:26 39 Employee2 2 2012-09-11 14:44:36 39 Employee2 1 2012-09-11 14:44:36 39 Employee2 2 2012-09-11 14:44:36 39 Employee2 1 2012-09-11 16:43:59 37 Employee1 1 2012-09-11 17:16:26 ---------------------------------------------------------------- Direction (From Above) 1 = Out 2 = In ----------------------------------------------------- I'm going to create a couple of different reports, but the first one will look like: Name Date Time In Time Out Time In Time Out Total Time: --------------------------------------------------------------------------------------- Employee1 9/9/12 20:53 20:53 0:00 9/10/12 09:08 17:10 8:02 9/11/12 08:14 12:51 14:44 17:16 7:09 ----------- 15:11 Employee2 9/10/12 7:58 17:03 9:05 9/11/12 8:14 12:53 14:44 16:43 7:11 ----------- 16:16 can someone point me in the right direction for this ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/272621-creating-a-report-from-a-table-i-have-the-logic-need-help-with-the-code/ Share on other sites More sharing options...
Jessica Posted January 2, 2013 Share Posted January 2, 2013 mysqli_query There are some good examples of doing queries in the manual. It's hard to point you in any direction if you don't say what you're having trouble with. Quote Link to comment https://forums.phpfreaks.com/topic/272621-creating-a-report-from-a-table-i-have-the-logic-need-help-with-the-code/#findComment-1402847 Share on other sites More sharing options...
egiblock Posted January 2, 2013 Author Share Posted January 2, 2013 i have this to generate a list of users and dates. just need to get the grouping and the logic down now.. <?php include 'includes/db.inc.php'; $result = mysqli_query($link, 'SELECT * FROM employeelog LIMIT 0 , 30' ); $ii=0; while ($row = mysqli_fetch_array($result)) { for($fst=0;$fst<$ii;$fst++){ $tr1name[$ii] = $row['name']; $tr1direction[$ii] = $row['direction']; $tr1dated[$ii] = $row['dated']; $tr1datet[$ii] = $row['datet']; } $ii++; } ?> Report Generation<br /><br /> <table> <tr> <td>name</td> <td>date</td> <td>In</td> <td>Out</td> <td>In</td> <td>Out</td> <td>In</td> <td>Out</td> </tr> <?php for($fst=0;$fst<$ii;$fst++){?> <tr> <td>a<?php echo $tr1name[$fst];?></td> <td>a<?php echo $tr1dated[$fst];?></td> </tr> <?php }?> </table> </head> </html> Quote Link to comment https://forums.phpfreaks.com/topic/272621-creating-a-report-from-a-table-i-have-the-logic-need-help-with-the-code/#findComment-1402850 Share on other sites More sharing options...
Jessica Posted January 2, 2013 Share Posted January 2, 2013 It's hard to point you in any direction if you don't say what you're having trouble with. By which I mean an actual specific problem, not just "I need to do X." That's just a statement of fact. Quote Link to comment https://forums.phpfreaks.com/topic/272621-creating-a-report-from-a-table-i-have-the-logic-need-help-with-the-code/#findComment-1402854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.