Jump to content

DOUBLE LIST BOXES


joesaddigh

Recommended Posts

Hi,

 

I have been trying to populate a listbox from the database and control another one based on the choice of the first. When i view my page the first list box does not display any text but it has the correct amount of options in there (they are blank) so it is returning the correct values from the db.

 

The code is below:

 

<?php
                    @$coursetitle=$_GET['coursetitle'];
                   
                    ///////// Getting the data from Mysql table for first list box//////////
                    $querytitle=mysql_query("SELECT DISTINCT CourseTitle FROM course");
                   
                    if(isset($coursetitle) and strlen($coursetitle) > 0){
                    $querylevel=mysql_query("SELECT DISTINCT courselevel FROM course where coursetitle=$coursetitle");
                    }
                        else{$querylevel=mysql_query("SELECT DISTINCT courselevel FROM course");
                    }
                   
                    echo "<form method=post name=f1 action='dd-check.php'>";
                   
               //////////        Starting of first drop downlist /////////
               echo "<select name='coursetitle' onchange=\"reload(this.form)\"><option value=''>Select Course</option>";
               while($noticia2 = mysql_fetch_array($querytitle))
               {
                  if($noticia2['coursetitle']==@$coursetitle)
                  {
                     echo "<option selected value='$noticia2[coursetitle]'></option>"."<BR>";
                  }
                  else
                  {
                     echo  "<option value='$noticia2[coursetitle]'>$noticia2[coursetitle]</option>";
                  }
               }
               
               echo "</select>";
               
               //////////        Starting of second drop downlist /////////
               echo "<select name='courselevel'><option value=''>Select Level</option>";
               while($noticia = mysql_fetch_array($querylevel))
               {
                  echo  "<option value='$noticia[courselevel]'>$noticia[courselevel]</option>";
               }
               echo "</select>";
               
               //////////////////  This will end the second drop down list ///////////
               //// Add your other form fields as needed here/////
               echo "<input type=submit value=Submit>";
               echo "</form>";
                  
                ?>

 

 

Any help would be greatly appreciated!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.