I'm trying to call the amountof comments in a news post. The problem is that the function works but it ends of posting the result at the top of the table above all the news entrys instead of where its supposed to go
function count_comments($news_id)
{
global $dbcon, $db;
$query = "SELECT comment_id FROM news_comments WHERE news_id = \"$news_id\"";
$result = @($query,$dbcon) or die("Couldn't execute query");
$count = mysql_num_rows($result);
echo "[Comments: $count]";
}
This part is inside the retrieve_news function...
$count = count_comments("$news_id");
$show_news .= "
<!----News Item $news_id---->
<table width=550 border=1 cellspacing=0 bordercolor=white>
<tr>
<td bgcolor=#CCCCCC bordercolor=black colspan=2><font class=\"smallest indent black\"><b>$news_date - $news_title<b></font></td>
</tr>
<tr>
<td bgcolor=#FFFFFF colspan=2>$news_body</td>
</tr>
<tr>
<td bgcolor=#FFFFFF align=right colspan=2> - <a style=\"color: black\" href=\"mailto:$news_poster_email?subject=$news_title\">$news_poster</a></td>
</tr>
<tr>
<td bgcolor=#FFFFFF>Source: <a style=\"color: black;\" href=\"$news_source_url\">$news_source</a></td>
<td bgcolor=#FFFFFF align=right><font class=\"smallest black\">$count</font></td>
</tr>
</table>
<!----News Item $news_id End---->
<br>
";