Hi, I am having problems with adding category to this code below $Threadquery = mysql_query("SELECT threadid, count(threadid) as count FROM comments GROUP BY threadid ORDER BY count DESC LIMIT $count , 1 ") or die(mysql_error()); PHP: Thanks
If I have understood you correctly, try this: $Threadquery = mysql_query("SELECT threadid, count(threadid) as count FROM comments WHERE category='travel' GROUP BY threadid ORDER BY count DESC LIMIT $count , 1 ") or die(mysql_error()); Code (markup):
<table width="378" border="0"> <tbody> <?php $Threadquery = mysql_query("SELECT threadid, count(threadid) as count FROM comments GROUP BY threadid ORDER BY count DESC LIMIT $count , 1 ") or die(mysql_error()); $Threaddata = mysql_fetch_array($Threadquery); $NoThreadquery = mysql_query("SELECT * FROM threads where threadid='".$Threaddata['threadid']."'") or die(mysql_error()); $NoThreadComments = mysql_fetch_array($NoThreadquery); ?> <tr valign="top"> <td width="15" align="center" valign="top"><span style="font-family: 'Palatino Linotype'; font-size: 14px; color: rgb(255, 255, 255);">+</span></td> <td width="353"><span style="font-family: 'Palatino Linotype'; font-size: 12px;"><a href="postdetails.php?thread=<?=$NoThreadComments['threadid'];?>&type=<?=$NoThreadComments['categoryid'];?>" rel="nofolloow" style="text-decoration: none; color: rgb(51, 102, 153);"><?=$NoThreadComments['title'];?></a><span style="color: rgb(143, 71, 143);"><br> by <?=$NoThreadComments['username'];?></span> <span style="color: rgb(237, 243, 254);"><?=$Threaddata['count'];?> comment(s)</span></span></td> </tr> </tbody></table> PHP: here is the full code.. right now the code shows threads from all categories, My aim is to show threads from category (travel) Thanks
Can you show the tables structures of the database? I mean the structure of the table comment and the structure of the table in which is the column category.