Jump to content

creating a report from a table. i have the logic, need help with the code.


egiblock

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.