#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    11

    Populate combobox


    i have three combo box ...depending on two combo box i want to populate third combo box....This is my code ..can any one help
    PHP Code:
    me...plez

    <?


    ///////// Getting the data from Mysql table for first list box//////////
    $quer2=mysql_query("SELECT DISTINCT startdate FROM info order by startdate"); 
    ///////////// End of query for first list box////////////

    /////// for second drop down list we will check if startdate is selected else we will display all the course///// 
    $cat=$HTTP_GET_VARS['cat']; // This line is added to take care if your global variable is off
    if(isset($cat) and strlen($cat) > 0){
    $quer=mysql_query("SELECT DISTINCT course FROM info where rimid=$cat order by course"); 
    }else{
    $quer=mysql_query("SELECT DISTINCT course FROM info order by course"); } 
    ////////// end of query for second subcategory drop down list box ///////////////////////////


    /////// for Third drop down list we will check if course is selected else we will display all the name///// 
    $cat3=$HTTP_GET_VARS['cat3']; // This line is added to take care if your global variable is off
    if(isset($cat3) and strlen($cat3) > 0){
    $quer3=mysql_query("SELECT name FROM info where course = $cat order by name"); 
    }else{
    $quer3=mysql_query("SELECT name FROM info order by name"); } 
    ////////// end of query for third subcategory drop down list box ///////////////////////////


    echo "<form method=post name=f1 action='dd3ck.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['rimid']==@$cat){echo "<option selected value='$noticia2[rimid]'>$noticia2[startdate]</option>"."<BR>";}
    else{echo  
    "<option value='$noticia2[rimid]'>$noticia2[startdate]</option>";}
    }
    echo 
    "</select>";
    //////////////////  This will end the first drop down list ///////////

    //////////        Starting of second drop downlist /////////
    echo "<select name='subcat' onchange=\"reload3(this.form)\"><option value=''>Select one</option>";
    while(
    $noticia mysql_fetch_array($quer)) { 
    if(
    $noticia['rimid']==@$cat3){echo "<option selected value='$noticia[rimid]'>$noticia[course]</option>"."<BR>";}
    else{echo  
    "<option value='$noticia[rimid]'>$noticia[course]</option
    >";}
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    425
    Rep Power
    0
    in your code you have use @ with variable name which is useless as @-operator works only on expressions.

    Comments on this post

    • sarav_dude agrees
    Last edited by ttremain; May 28th, 2009 at 07:57 AM.

IMN logo majestic logo threadwatch logo seochat tools logo