Thanks bogu - I think with your help I've got it figured out - I ended up doing the following:
Created foreign key on Entries (aka: "blog") table against the corresponding column (id) in the Topic table:
ALTER TABLE blog ADD CONSTRAINT fk_topic_id
FOREIGN KEY (topic) REFERENCES topic(id)
And then run the following query to fetch all the data needed out of Topic, plus a count on corresponding entries in Blog in the same results set:
SELECT t.id, t.prmry, t.topic, t.author, t.date, COUNT( bl.topic )
FROM topic t, blog bl
WHERE t.id = bl.topic
GROUP BY bl.topic
So the end result:
if(isset($_SESSION[user_id])) {
$query = "SELECT t.id, t.prmry, t.topic, t.author, t.date, COUNT( bl.topic )
FROM topic t, blog bl
WHERE t.id = bl.topic
GROUP BY bl.topic
ORDER BY date DESC LIMIT $offset, $limit";
}
$res = @($query, $sql);
while($row = mysql_fetch_array($res)) {
$id = $row[0];
$prmry = $row[1];
$topic = $row[2];
$author = $row[3];
$date = $row[4];
$count = $row[5];
echo stuff here
}
Thanks again...problem solved,
Adam