I have a problem about Blog Post Categorization Script. Can anyone review it ? Instead of showing how much posts that category have it just repeats.
<?
$sqlCategories = "SELECT * FROM blog_entry, categories where blog_entry.CategoryID=categories.CategoryID and blog_entry.UserID=".$_REQUEST['UserID']." order by Category asc";
$resultCategories = mysql_query($sqlCategories, $conn);
if (@mysql_num_rows($resultCategories)!=0){
$strcategory="";
while($row_categories = @mysql_fetch_array($resultCategories))
{
$categoryduplicate=0;
$arrcat = explode(",",$strcategory);
for($i=0;$i<strlen($arrcat);$i++)
{
if($arrcat[$i]==$row_categories['CategoryID'])
{
$categoryduplicate=1;
}
}
if($categoryduplicate==0)
{
if($strcategory=="")
{
$strcategory=$row_categories['CategoryID'];
}
else
{
$strcategory=$strcategory.",".$row_categories['CategoryID'];
}
$sqlCategories2 = "SELECT * FROM blog_entry where CategoryID=".$row_categories['CategoryID']." and UserID=".$_REQUEST['UserID'];
$resultCategories2 = mysql_query($sqlCategories2, $conn);
if($row_categories['CategoryID'] == $_REQUEST['CategoryID'])
{
echo "
<Tr>
<td class='content'><a href='postss.php?CategoryID=".$row_categories['CategoryID']."&UserID=".$_REQUEST['UserID']."&Category=".$row_categories['Category']."' class='in_sel'>".$row_categories['Category']."</a> [".@mysql_num_rows($resultCategories2)."]</td>
</Tr>
";
}
else
{
echo "
<Tr>
<td class='content'><a href='posts.php?CategoryID=".$row_categories['CategoryID']."&UserID=".$_REQUEST['UserID']."&Category=".$row_categories['Category']."' class='in_sel'>".$row_categories['Category']."</a> [".@mysql_num_rows($resultCategories2)."]</td>
</Tr>
";
}
}
}
}
?>