I have a course management php page with a database connected in the backend with courses, modules, and modules in a specific course.
I have a form with a dropdown list with options to select a course. Underneath I would like a list of modules in the chosen course from the dropdown list above to show as list item elements. My php code for the form is below. How would I do this using php?
<form method="post" action="courseManagement.php">
<table>
<center> <span>Course Management<span></center><P><P><P>
<tr>
<td>Choose course to add module: </td>
<td> <?php
$sql = "SELECT courseName FROM course";
$result = mysql_query($sql);
echo "<select name='courseName'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['courseName'] ."'>" . $row['courseName'] ."</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>
Modules in the choosen course
</td>
<td>
<li>Projects and management</li>
<li>Programming 2</li>
<li>Business Analysis</li>
</td>
</tr>
<tr>
<td>Choose module to add to course: </td>
<td> <?php
$sql = "SELECT moduleName FROM module";
$result = mysql_query($sql);
echo "<select name='moduleName'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['moduleName'] ."'>" . $row['moduleName'] ."</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>Choose module to delete from the course: </td>
<td> <?php
$sql = "SELECT moduleName FROM module";
$result = mysql_query($sql);
echo "<select name='moduleName'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['moduleName'] ."'>" . $row['moduleName'] ."</option>";
}
echo "</select>";
?>
</td>
</tr>
</table><p><br>
<center>
<input type="submit" value="Update">
</center>
</form>