Hi guyz , am trying to link to tables, when a user selects one category it should bring projects only associated with the selected category

am some how not able to select and link  specific categories below is my code ..n ideas will be appreciated


<?
$cpid = $_GET['id'];

//db connection is here



@$cat=$_GET['cat'];
if(strlen($cat) > 0 and !is_numeric($cat)){ // to check if $cat is numeric data or not.
echo "Data Error";
exit;
}


@$cat=$HTTP_GET_VARS['cat'];

///////// Getting the data from Mysql table for first list box category//////////
$quer2=mysql_query("SELECT DISTINCT aacid,categoryname FROM app_categories order by categoryname");
///////////// End of query for first list box////////////

///////  second drop down list we will check if category is selected else we will display all the project/////
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT user_id ,apid,category_id ,projectname FROM projects join app_categories on aacid =category_id  where aacid=$cpid order by projectname asc");
}else{$quer=mysql_query("SELECT  projectname FROM projects order by projectname"); }
////////// end of query for second subcategory drop down list box ///////////////////////////


/// Add your form processing page address to action in above line.////

echo "<form method=post name=f1 action='dd-check.php'>";
//////////        Starting of first drop downlist /////////
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['aacid']==@$cat){echo "<option selected value='$noticia2[aacid]'>$noticia2[categoryname]</option>"."<BR>";}
else{echo  "<option value='$noticia2[aacid]'>$noticia2[categoryname]</option>";}
}
echo "</select>";
//////////////////  This will end the first drop down list ///////////

//////////        Starting of second drop downlist /////////
echo "<select name='subcat'><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) {
echo  "<option value='$noticia[aacid]'>$noticia[projectname]</option>";
}
echo "</select>";
//////////////////  This will end the second drop down list ///////////

echo "<input type=submit value=Submit>";
echo "</form>";
?>


this is dd-check.php



<html>

<head>
<title></title>

</head>

<body>
<?
$cat=$_POST['cat'];
$subcat=$_POST['subcat'];

echo "Value of \$cat = $cat <br>Value of \$subcat = $subcat ";


?>

</body>

</html