Hello All!
The following code loops through the data and displays the data accordingly. My problem is that the $listPR->HoursWorked; array repeats itself. The foreach($listLocations as $listLoc) loops and displays the locations but the data array for HourWorked doesn't change per location. I'm not sure that this is a MySQL question but here is the SQL Statement: I can't figure out where I would "break" the loop and start it again to display the information correctly per location? Can someone give me a hand on this one? Thanks for the help in advance!
Code: [Select]<?php
$locSql = "SELECT * FROM Location AS loc WHERE companyID=". $_SESSION['company_id'] ." AND (" . $selLoc . ")";
$listLocations = locData::find_by_sql($locSql);
$sql = "SELECT *,
DATE_FORMAT( Clockin, '%H:%i' ) AS FormattedTimeIn,
DATE_FORMAT( Clockout, '%H:%i' ) AS FormattedTimeOut,
TIMEDIFF( Clockout, Clockin ) AS HoursWorked
FROM time_clock AS tc
JOIN employees AS e ON e.Id = tc.Emp_id
JOIN location AS loc ON loc.LocationID = tc.LocationID
JOIN employmentdetail AS ed ON ed.UserId = e.Id
WHERE tc.Clockin BETWEEN '".$Date1."' AND '".$Date2."'
AND (" . $selLoc . ") AND ed.Active = 1
ORDER BY e.LastName ASC";
$listPayrollSum = mysql_query( $sql );
?>
And here is the loop that I'm having trouble getting to not duplicate the data:
Code: [Select]<?php
<!-- Loop thru and generate output -*** Based on Number of Employees and Number of Locations *** Some data may return NULL for location
foreach Loop < tr > # of Employee create table cells -->
<?php while( $listPR = mysql_fetch_object( $listPayrollSum ) ) { $row_count++; ?>
<tr class="grid-content"<?php if ($row_count%2) { ?> bgcolor="#ebebeb" <?php } ?> >
<td style="padding:5px;" ><?php echo $listPR->LastName. ", " .$listPR->FirstName ?></td>
<!-- foreach Loop < # of Locations > -->
<?php foreach($listLocations as $listLoc){ ?>
<td style="padding:5px; border-left:#333 1px solid;" align="center"> <?php echo $listPR->HoursWorked;?> </td>
<td style="padding:5px;" align="center">$2,400.80</td>
<td style="padding:5px;" align="center">$1,000</td>
<?php } ?>
<!-- End foreach Loop < Locations > -->
<!-- Total -->
<td align="center" style="border-left:#333 1px solid;"> </td>
<td align="center" style="padding:5px; border-left:#333 1px solid;" >2000</td>
<td align="center" style="padding:5px;" >$25,000.00</td>
<td align="center" style="padding:5px;" >$6,000,000.00</td>
</tr>
<?php } ?>
<!-- End Loop for Employee -->
?>
Problem with PHP/mySQL login code
Hello,There is an error in my login script and I can't figure out what it is...I believe it might be my "SELECT" statement...Can anyone help me? Code: <?php//define ('SASI Services
Oracle Connectivity
Hi Every One,
get the country of visitor and display content based on that
Hello all,I have seen that Google analytics can tell you where a visitor is coming from and I want to do something similar. But I would like to add the functionality of redirecting a user based on his
problem in pagination when processing with selectbox form
Hi,I have a search form, with select boxes, if am selecting the value from the form, it works good, but when i am integrating the pagination script, it messed up.this is my script...please help me
LinkedList help
Ok so I just learned quickly about lists, so I have a not too hard project I think, but am having a few issues:Here is the project. Create a lovely polynomial calculator, that takes the equation from
Undefined variables
hi----------------------------------------------------------------------------------------------------error log "[Sat Jan 09 17:40:00 2010] [error] [client 127.0.0.1] PHP Notice: Undefined
ok i need to join all this pages to make 1 neat code
i have 5 pages that make up my tv guide it works 100% but i want to make it 1 page if i can or 2, i want it to have diff pages for each guide but all the code on 1 page i just dont know how to do it,
array_diff weirdness
I'm using the following bit of code$diff = array_diff($pids, $pidlist); $diff = array_values($diff); //reindex array to remove empties//output to $discrepancyprint_r($diff);exit;Both $pids and
Blank record injected into database
I always found several blank records inside my database, although $SESSION is required to insert the data into database.Why can this happen? how to prevent this?
Array becomes unset by itself?
Hi,I have a bit of experience with PHP but not extensive. It seems I cannot store any items to the array $details. The class:class Newsletter {public $details = array();function Newsletter($id)