
First you dont need the line *@$cat=$HTTP_GET_VARS['cat']* Secondly, in join queries you need to define the tables.tablecolumn and not just tablecolumn. Third, you haven't used this $cat variable in your sql statements anywhere. As an example of the second and third points: */////// 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 app_categories.user_id ,app_categories.apid,app_categories.category_id ,projects.projectname FROM projects join app_categories on projects.aacid =app_categories.category_id where projects.aacid=$cpid and app_categories.cat_id = $cat order by projectname asc"); * Please notice that I don't know your project therefore many of the variables in that SQL statement may need to be corrected. Otherwise that is a general sql join statement format. On Sun, May 8, 2011 at 2:09 PM, Imelda Mueni <mueni.imelda1@gmail.com>wrote:
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*
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------ Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- www.golavish.com - The travel and leisure www.raccuddasys.com - code Development issues