0

Im writing a function to get the parent and child ids but for the third loop there is a

problem the loop gets even the previous loops id also .

How can i avoid it?

<?
$results = '
<table>
    <thead>
        <tr >
            <td id="ticket" align="center" ><b>Task<br />ID</b></td>
            <td id="ticket" align="center" ><b>col1</td>
            <td id="ticket" align="center" ><b>col2</td>
</tr>
    </thead>
    <tbody>';

while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) 
{
$results .='
        <tr >
            <td align="center">
                <a href="UpdateTask.php?TaskID='.$row['Task_id'].$filterstring.'">'.$row['Task_id'].'</a>
            </td>';

    $results .= '<td align="center">'; 
      $gg = mysqli_query($dbc,"select * from Tasks where ParentTask_Id='".$row['Task_id']."'");
      echo "<br>";     
            while ($rowdd = mysqli_fetch_assoc($gg)) 
      {
       $results .= $rowdd['Task_id']."<br><br>"; 
       $gg2 = mysqli_query($dbc,"select * from Tasks where ParentTask_Id='".$rowdd['Task_id']."'");
       while ($rowdd2 = mysqli_fetch_assoc($gg2)) 
      {
         $results2 = $rowdd2['Task_id']."<br><br>";
      } 
      echo "<br>";    
      } 
    // $results .= $car ;
        // $results .=  $t; 
            $results .='</td>';
             $results .=' <td  align="left" >'?>
        <?
        $results .= $results2;  
        $results .='</td>';
$results .='
        </tr>';
}
?>
2
  • Looks like you're missing at at least a ' in the above code. Any chance you can actually post what is currently in your file, and clarify the value of $r? Commented Sep 6, 2011 at 20:47
  • None of your queries are checking for error conditions. Should have, at bare minimum, mysqli_query(...) or die(mysqli_error($dbc)); Commented Sep 6, 2011 at 21:11

1 Answer 1

1

Is the $results variable empty? I only see it being concatenated.

Also, on your table you have multiple ids that are the same. You either need to change that to a class or have a unique value for each id.

Sign up to request clarification or add additional context in comments.

2 Comments

NO results variable is not empty .
I have the problem in the third while loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.