mustafaneguib 1 Junior Poster in Training

hey guys, i have encountered a small problem.
currently my table layout is as is shown in the image.
http://www.worldofpakistan.net/graphic1.gif

wat i want is the categories with the same id to merge into one, and all the relevent forums come under one category like phpbb and the other forums do.
my original logic didnt work the way i wanted to do and now i am pretty mych at a dead end.

i want something like in the following image.
http://www.worldofpakistan.net/graphic2.gif


thanx in advance.

<?php

session_start();

$authuser=$_SESSION['authuser'];
$userid=$_SESSION['userid'];
$usertype=$_SESSION['usertype'];
$username=$_SESSION['username'];
$captcha=$_SESSION['captcha'];


include '../config.php';
include '../sitename.php';


$getcommunitystatus="SELECT *
					FROM features
					WHERE feature_name='community'";
					
$query=mysql_query($getcommunitystatus)
          or die(mysql_error());

$row=mysql_fetch_array($query);

extract($row);

$activecommunity=$active;



if($activecommunity==0)
{
header("Location: ../index.php");
exit(0);
}


?>


<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head><title><?php echo $sitename;?>--Community</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keyword" content="" />
<meta name="description" content=" " />
<meta http-equiv="content-language" content="en" />



<!--Developer: MN Tech Solutions-->
<!--Software: MN Tech Solutions Content Management System Software (MNTSCMSS)-->
<!--Version: 0.0 Stable Version-->
<!--Designer/Programmer: Mustafa Neguib-->
<!--Date Project Started: 7th July 2008-->
<!--
-->

<?php

include('../styles/black-white-theme/browsercheck.php'); 
?>



<style type="text/css">

<!--

-->
</style>
</head>
<body>

<div id="div1">

<div id="div2">

<br />

 <img src="../styles/black-white-theme/images/logo.gif" alt="Logo" title="Logo" />


</div>

<div id="div3">
<div id="links">
<?php

if($authuser==0)
{
echo "<ul>";
echo "<li><a href='../index.php' title='Home'>Home</a></li>";
if($activecommunity==1)
{
echo "<li><a href='../login/login.php?check=1' title='Login'>Login</a></li>";
echo "<li><a href='../register.php' title='Register'>Register</a></li>";
echo "<li><a href='../community/index.php' title='Community'>Community</a></li>";
echo "<li><a href='../memberlist.php?start=0' title='Member List'>Member List</a></li>";
}
echo "<li><a href='../custom/index.php?start=0' title='More Sections'>More Sections</a></li>";
echo "</ul>";
 }

else 
{

 if($usertype==0)
 {
echo "<ul>";
echo "<li><a href='../index.php' title='Home'>Home</a></li>";
if($activecommunity==1)
{
echo "<li><a href='../community/index.php' title='Community'>Community</a></li>";
echo "<li><a href='../memberlist.php?start=0' title='Member List'>Member List</a></li>";
}
echo "<li><a href='index.php?start=0' title='More Sections'>More Sections</a></li>";
echo "<li><a href='../logout.php' title='Log Out'>Log Out</a></li>";
echo "</ul>";
}
else
{
echo "<ul>";
echo "<li><a href='../index.php' title='Home'>Home</a></li>";

if($activecommunity==1)
{
echo "<li><a href='../community/index.php' title='Community'>Community</a></li>";
echo "<li><a href='../memberlist.php?start=0' title='Member List'>Member List</a></li>";
}
echo "<li><a href='../custom/index.php?start=0' title='More Sections'>More Sections</a></li>";
echo "<li><a href='../logout.php' title='Log Out'>Log Out</a></li>";
echo "</ul>";
}
}
 

?>
</div>
</div>


<div id="div4">
<?php
if($authuser==0)
{
include '../login/simplelogin.php';
}


?>
</div>

<div id="div5">

<?php


$getcategory="SELECT category.cat_id, category.cat_name
				FROM category
				ORDER BY category.cat_id";
				
$querygetcategory=mysql_query($getcategory)
or die(mysql_error());

$getforum="SELECT forum.forum_id, forum.forum_name, forum.forum_desc, forum.is_open_forum, forum.cat, category.cat_id, category.cat_name
          FROM forum, category
		  WHERE forum.cat= category.cat_id
		   ";

$querygetforum=mysql_query($getforum)
or die(mysql_error());

echo "<br />";



while($forumrow=mysql_fetch_array($querygetforum))
{
echo "<table border=\"1\" width=\"600px\" align=\"center\">\n";
extract($forumrow);
echo "<tr>\n";
echo "<th colspan=\"3\">\n";
echo "Category: ".$cat_name;
echo " ";
echo $cat_id;
echo "</th>\n";
echo "</tr>\n";
if($is_open_forum==1)
{
echo "<tr>\n";
echo "<td rowspan=\"2\">\n";
echo "open";
echo "</td>\n";
echo "<td>\n";
echo $forum_name;
echo "</td>\n";
echo "<td rowspan=\"2\">\n";
echo $thread_name." go";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>\n";
echo "Description";
echo "</td>\n";
echo "</tr>\n";
}
else
{

echo "<tr>\n";
echo "<td>\n";
echo "closed";
echo "</td>\n";
echo "<td>\n";
echo $forum_name;
echo "</td>\n";
echo "<td>\n";
echo $thread_name." go";
echo "</td>\n";
echo "</tr>\n";

}

echo "</table>\n";
echo "<br />";
}






?>

</div>

<br /><br />

</div>




<div id="div9">
<?php

include '../footer.php';
?>

</div>

</body>
</html>