Lid |
|
Hallo,
Mijn sql tabellen zien er als volgt uit
forum_cats
+---------+
|cid | title |
+---------+
forum_forums
+---------------+
|fid | title | cid |
+---------------+
forum_topics
+-----------------------+
|tid | title | poster | fid |
+-----------------------+
forum_reactions
+--------------------------+
|rid | bericht | poster | tid |
+--------------------------+
Nu is dit mijn code, en voor topics is dit al gelukt maar ik zou graag weten of het ook voor reacties zou kunne met een count?
hier de code :
<?php while ($data = mysql_fetch_assoc($query_cats)) { ?>
<div class="m_boxtop"><?php echo $data['cat']; ?></div>
<table style="border: 1px solid #CCCCCC;border-top:0px;border-bottom: 0px;margin-bottom: 10px;" width='100%' cellpadding='5' cellspacing='0'>
<?php
$query_forums = mysql_query("SELECT * FROM forum_forums WHERE cid='".$data['cid']."'");
while ($data2 = mysql_fetch_assoc($query_forums)) {
$sqltopics = mysql_query("SELECT Count(tid) FROM forum_topics WHERE fid='".$data2['fid']."'");
$resulttopics = mysql_result($sqltopics,0);
?>
<tr>
<td width=5% style="border-bottom: 1px solid #CCCCCC;"><img src="images/icons/brick.jpg"></td>
<td width=30% style="border-bottom: 1px solid #CCCCCC;"><b><a href="index.php?mod=forum&act=list&id=<?php echo $data2['fid']; ?>"><?php echo $data2['title']; ?></a></td>
<td width=15% style="border-bottom: 1px solid #CCCCCC;"><?php echo $resulttopics; ?> Topics</td>
<td width=15% style="border-bottom: 1px solid #CCCCCC;"><?php echo iets ?> Posts</td>
<td width=35% style="border-bottom: 1px solid #CCCCCC;">The matrix revisited</td>
</tr>
<?php } ?>
</table>
<div class="m_boxtop"> <?php echo $data['cat']; ?></div> <table style="border: 1px solid #CCCCCC;border-top:0px;border-bottom: 0px;margin-bottom: 10px;" width='100%' cellpadding='5' cellspacing='0'> <?php $query_forums = mysql_query("SELECT * FROM forum_forums WHERE cid='".$data['cid']."'"); $sqltopics = mysql_query("SELECT Count(tid) FROM forum_topics WHERE fid='".$data2['fid']."'"); ?> <tr> <td width=5% style="border-bottom: 1px solid #CCCCCC;"><img src="images/icons/brick.jpg"></td> <td width=30% style="border-bottom: 1px solid #CCCCCC;"><b><a href="index.php?mod=forum&act=list&id= <?php echo $data2['fid']; ?>"> <?php echo $data2['title']; ?></a></td> <td width=15% style="border-bottom: 1px solid #CCCCCC;"> <?php echo $resulttopics; ?> Topics</td> <td width=15% style="border-bottom: 1px solid #CCCCCC;"> <?php echo iets ?> Posts</td> <td width=35% style="border-bottom: 1px solid #CCCCCC;">The matrix revisited</td> </tr> <?php } ?> </table>
|