Hi all. I need some help with this loop.
sql3 will select all data from table1 when a column "Gameid" equals to an id number. sql4 will then select data when the column "Hid" from table2 matches with the column "Hid" too from sql3. I'm trying to get the loop to work so that it will show all the results in table2 where column Hid is equal to Hid from sql3. Right now, it only shows the last result.
Code:
$sql3 = "SELECT * FROM $table1
WHERE Gameid='$Id' ORDER BY Territory ASC";
$db->query($sql3);
while ($db->next_record()) {
$Territory = $db->f(Territory);
$TotalCodes = $db->f(TotalCodes);
$Date = $db->f(Date);
$Hid = $db->f(Hid);
$sql4 = "SELECT Nick, Email FROM table2
WHERE Hid='$Hid'";
$db->query($sql4);
while ($db->next_record()) {
$Nick = $db->f(Nick);
$Email = $db->f(Email);
$color = ($i++ % 2 ) ? '#000000' : '#333333';
$tmp3 = "<tr bgcolor='$color'><td> <font size='2' face='Verdana, Arial'>
<a href='http://www.xplodercodes.com/codes/dreamcast/codes/codes.phtml?id=$Id'>$Territory</a></font>
</td><td> <font size='2' face='Verdana, Arial'>$TotalCodes</font></td><td>
<font size='2' face='Verdana, Arial'>$Date</font></td><td> <font size='2' face='Verdana, Arial'>
<a href='mailto:$Email'>$Nick</a>
</font></td></tr>";
$t->set_var('data', $tmp3);
$t->parse('CBlock', 'CodesBlock', true);
}
}