Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5988053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:54:16+00:00 2026-05-22T22:54:16+00:00

In the loops below, PHP doesn’t seem to pass the outputted string back out

  • 0

In the loops below, PHP doesn’t seem to pass the outputted string back out to the loop that contains it for further manipulation, then making the output from this loop nothing at all.

Please help me understand why this is…

<?php

$finalTablePrint = '<html><body style="font-family:Tahoma, Verdana, Geneva, Arial, Helvetica, sans-serif; font-size:40px;">
                        LTU Activity Report<br/>
                        <span style="font-size:18px;">&nbsp;&nbsp;Date Created: ' . date("l jS \of F Y") . '<br/><br/>
                        <table width=100% style="background-color:white; font-size:12px; border-collapse:collapse;" >
                        <tr style="font-size:12px; font-weight:600; background-color:#d2dbdf; height:35px;">
                            <td>Activity</td><td>Department</td><td>Hours Spent</td><td>Month</td>
                        </tr>';

while ($row = mysql_fetch_assoc($result)) {
    $finalTablePrint .= '<tr><td colspan=4>' . $row['activity'] . '</td></tr>';
    while ($row_1 = mysql_fetch_assoc($result)) {
        if ($row_1['activity'] == $row['activity'] && $row_1['department'] == $row['department']) {
            $finalTablePrint .= '<tr style="height:30px;"><td colspan=3>' . $row['department'] . '</td>' . '<td>' . $row['hours'] . '</td><td>' . $row['month'] . '</td></tr>';
        }
    }
}

echo $finalTablePrint .='</table><script type="text/javascript">javascript:window.print(); setTimeout(\'window.location="../../admin/index.php"\',"1000");</script></body></html>';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:54:17+00:00Added an answer on May 22, 2026 at 10:54 pm

    Note that when you set off your second loop, you are calling the same SQL statement as the original one before it

      while ($row = mysql_fetch_assoc($result)) {   //1st while
    while ($row_1 = mysql_fetch_assoc($result)) {    //2nd while
    

    which in turn means that this if statement will allways be true….

     if ($row_1['activity'] == $row['activity'] && $row_1['department'] == $row['department']) { 
    

    and this will allways echo:

      $finalTablePrint .= '<tr style="height:30px;"><td colspan=3>'.$row['department'].'</td>'.'<td>'.$row['hours'].'</td><td>'.$row['month'].'</td></tr>';  
    

    so you should really remove your 2nd while/if statement… since it achieves nothing at the moment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The loop below is callign a proc that does various 'things' If it should
The code below shows me (I think) that the for each loop is about
I'm having some problems with the php script below that I'm currently working on.
In the below code there's a loop that features all products under a given
How can I eliminate duplicate in an array using PHP, array looks like below
I have a Perl script which nests foreach loops as seen below. It takes
My jpa looks like below public class TESTClass implements Serializable { ... private String
In the below code I'm trying to loop through each child node and append
How can I loop through the array below and an element per array, with
I am trying to loop the below iteration, the code is below and i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.