mardi 26 juillet 2016

Select option from dropdown menu with PHP and mySql

I tried to create the simple select drop down menu from mysql database. However, it does not work on my code.

Here is my code:

            <?php
              mysql_select_db($database_conn, $conn);
              $query_RsCourse = "SELECT * FROM tbl_course ORDER BY courseid DESC";
              $RsCourse = mysql_query($query_RsCourse, $conn) or die(mysql_error());
              $totalRows_RsCourse = mysql_num_rows($RsCourse);
              $count=0;
              while ( $row = mysql_fetch_array($RsCourse, MYSQL_ASSOC)) {
              $courseid=$row["courseid"];
         $count++;  
              }
             ?>

            <tr>
            <td bgcolor="#CCCCCC">&nbsp;Course Name</td>
            <td bgcolor="#dfdfdf">&nbsp;<select name="courseid">
            <option value="" SELECTED>Selected Course</option>      
            <option value="<?php echo $courseid; ?>"><?php echo $row_RsCourse['$courseid']; ?></option>
            </select>
            </td>
            </tr>

Any advice will be appreciated!

Aucun commentaire:

Enregistrer un commentaire