Skip to main content
edited title
Link
j08691
  • 208.5k
  • 33
  • 269
  • 281

drob Drop down list from mysqlMySQL in htmlHTML page

Source Link
Sara S'h
  • 85
  • 3
  • 9

drob down list from mysql in html page

im trying to put a drop down list generated from mysql in html page , the thing is this code work fine in a php page but it doesnt in html page , I've put it in a php tags yet nothing was shown , I would appreciate any help here is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <title>Add Qustions</title>
 </head>
 <body>
  <form action="saveQ.php" method="post" >

  <br />
  <?php   $connectdb = mysql_connect('localhost','root','sara') or die ("Not Connect");
  if (!$connectdb)
  {
      die('Could not connect :'. mysql_errno());
  }
  $selestdb  = mysql_select_db('iexa', $connectdb) or die ("not selected database");
   $qu = mysql_query("SELECT ID,Name FROM Course ORDER BY ID asc") or die ("mysql error");
    echo "Choose the course that you want to create the test for : <br /> ";
    echo " <select name='courseID' >Course</option>";
    echo "<option value=0>Course </option>";
     $curvalue=2;
    while  ($row = mysql_fetch_assoc($qu)){
    echo '<option value="' .$row[ID].'">' .$row[ID].' ' .$row[Name].'</option>';
    $curvalue = $curvalue+1;
     }
     echo "</select> "; ?>
     <br />
      /// some other unrelated code here 
    <input type="submit" value="Save Question" />
    </form>

    </body>
    </html>