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
https://forums.phpfreaks.com/topic/148751-double-list-boxes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.