inspireddesign Posted October 16, 2009 Share Posted October 16, 2009 Hello, I have a small problem that can't seem to figure out. The following code loops through the array and displays the information accordingly. But my problem is that second echoed array doesn't get displayed. I think it's getting overwritten? Not sure. Can some help me, please? Thanks. <?php \<?php foreach($listLocations as $listLoc){ ?> <td style="padding:5px; border-left:#333 1px solid;" align="center"> <?php $locSql = "SELECT *, FLOOR(SUM(TIMEDIFF( Clockout, Clockin ))) AS HoursWorked FROM time_clock AS tc WHERE tc.Clockin BETWEEN '".$Date1."' AND '".$Date2."' AND tc.LocationID = " . $listLoc->LocationID . " AND tc.Emp_Id = " . $listPR->Id . " GROUP BY tc.Emp_Id"; $Hours = mysql_query( $sql ); $listHours = mysql_fetch_object( $Hours ); echo $locSql; echo $listHours->HoursWorked; ?> </td> <td style="padding:5px;" align="center">$2,400.80</td> <td style="padding:5px;" align="center">$1,000</td> <?php } ?> Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 16, 2009 Share Posted October 16, 2009 $listLoc->LocationID $from the code presented, $listLoc is not an object. and i don't see a second array? Quote Link to comment Share on other sites More sharing options...
inspireddesign Posted October 16, 2009 Author Share Posted October 16, 2009 Here's all the code. The SQL objects are getting displayed when i echo the the SQL statement. <?php <?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->Id . " " . $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 $locSql = "SELECT *, FLOOR(SUM(TIMEDIFF( Clockout, Clockin ))) AS HoursWorked FROM time_clock AS tc WHERE tc.Clockin BETWEEN '".$Date1."' AND '".$Date2."' AND tc.LocationID = " . $listLoc->LocationID . " AND tc.Emp_Id = " . $listPR->Id . " GROUP BY tc.Emp_Id"; $Hours = mysql_query( $sql ); $listHours = mysql_fetch_object( $Hours ); //echo $locSql; if( $listHours->HoursWorked == NULL ) { echo '0'; } else { echo $listHours->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 > --> ?> Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 16, 2009 Share Posted October 16, 2009 second echoed array i'm still not seeing this^ you can't 'echo' an array, it will just return: Array Quote Link to comment Share on other sites More sharing options...
inspireddesign Posted October 16, 2009 Author Share Posted October 16, 2009 My problem is that the data generated from the SQL is not being displayed. I know there's data there because I tested it. It should loop though and provide me with the output from the HoursWorked field that is created in the SQL statement. There are no errors in the sql syntax (i checked). Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 16, 2009 Share Posted October 16, 2009 had you said this: My problem is that the data generated from the SQL is not being displayed.should've said this right off the bat. gotta get right to the problem at hand. this would be your culprit then: $Hours = mysql_query( $sql ); should be: $Hours = mysql_query( $locSql ); right? Quote Link to comment Share on other sites More sharing options...
inspireddesign Posted October 16, 2009 Author Share Posted October 16, 2009 WOW... OMG! I'm SO sorry. You are right. Damn. Thanks. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted October 16, 2009 Share Posted October 16, 2009 WOW... OMG! I'm SO sorry. You are right. Damn. Thanks. don't apologize .. you're looking for a larger problem because these kinds of mistakes are assumed correct. next time, for yourself, work your way back from the problem, starting with the problem: query is working (no errors), just not getting the results .. must check $variables, etc. and be (as) short (as possible) and sweet with your problem .. when you eventually said: My problem is that the data generated from the SQL is not being displayed. i knew exactly where to look. glad i could help. Quote Link to comment 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.