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

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>

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.

Archived

This topic is now archived and is closed to further replies.

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