I'm try to query another table whilst inside an existing loop. Is this possible?
So i'm taking a variable from the outer loop and trying to use that variable to get data from another table.
The following just wipes out my queries altogether...
<?php $sql = "SELECT t1.id as messageID, t1.from_id, t2.full_name, t2.title FROM table1 t1 JOIN table2 t2 on t2.id = t1.user_id WHERE t1.user_id = '$userid' AND t1.unread = 0";
$result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) {; $from = $row["from_id"]; $messageID = $row["messageID"]; ?>
<tr>
<td><?php echo $row["full_name"];?></td>
<td><?php echo $row["title"];?></td>
</tr>
<?php }; }; ?>