i must be able to extract the results of this query and use it as another value for "Parent" in the succeeding "THE SAME QUERY". Right here, the value of parent in WHERE clause is "1". Now, I want to create the same query but the value of the parent is the result of the query below.
Thanks a lot! ^_^
//RIGHT HERE I GET THE TOTAL OF LEVEL RESULT OF LEVEL1
$result = mysql_query("SELECT COUNT(*) FROM agents WHERE sponsor = '$parent'")or die(mysql_error());
$output = array();
while ($row = mysql_fetch_array($result)) {
$lvl1 = $row['COUNT(*)'];
echo "<b>Total Level 1 Downlines</b> : ";
echo " <tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>$lvl1 <br><br>";
}
//NOW, I GET THE ID OF FIRST LEVEL RESULTS SO I CAN USE IT AS PARENT OF THE SAME QUERY ON LEVEL 2
$result = mysql_query("SELECT id, lastname FROM agents WHERE sponsor = '$parent'")or die(mysql_error());
$output = array();
while ($row = mysql_fetch_array($result)) {
$output[] = "sponsor = '".$row['id']."' ";
}
$newparent = implode(' or ', $output);