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 -->
?>
radio button reamains checked
Hello i'm trying to keep the state off my radio buttons so it shows which ones where clicked after the submit button is clicked im new to this so bare with me.heres my code <?phpforeach($_POST
Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and then decoded. For security and later readability.
How to replace search button with link?
hi to everbody.i have a search submit form and button like this :<form id="f1" name="title" method="post"
Access database inside of a validation class
Hello,For quite some time, I have been using functions to validate form input and access the databse. I have recently started using OOP, which is far faster and better when it comes to programming
Fetching META TAGS through
Hello everybodyI want to fetch meta tags of a domain.It will be done from following code of index.phpCode: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
FTP Programs
Here is a list of commonly suggested FTP Programs to use:FileZillaSmartFTPCuteFTPRightFTPCoreFTPJFTPFireFTP
Business Health Check
Hello I need to create an online business health check for a client it will be multiple choice and about 50 questions but the client has requested that the output/results of the health check needs to
newbie question
Hi out thereIm totaly new in this forum and to .net and vb so here is a totaly newbie question.I want to make a couter display how many times ive clicket a buttonWhy does my code alwas start over at 0
question about header() security
is is safe to just use the header() function to redirect someone if they are, say, not logged in? or should i always put a die() function underneath the header() function?
highlighting search terms
well, I started this in the regular PHP section, but it no longer fits there. Suffice it to say, I'm trying to take individual search terms that are being $_POSTed and highlighting them in the search