The below code displays a form with a drop-down list that populates the fields of the form when an option is selected from the list. I want to select an option from the drop-down list and use that selection to create a table when the Schedule
button is pressed. The problem I am having is the table that is getting created actually contains every training course that matches the sql query, and not just the one training course that I selected. I only want to display the one training course and say that it was scheduled, not the entire database full of training courses that match the query.
<?php
include 'reportBox.php';
?><br><br>
<form name = "reportForm" action = "scheduleCourse.html.php" onsubmit="return confirmcheck()" method="POST">
<input type="hidden" id="courseID" name="courseID" disabled>
<label for="tcTitle">Title:</label>
<input type="text" name="tcTitle" id="tcTitle" disabled /><br/><br>
<label for="tcProvider">Provider:</label>
<input type="text" id="tcProvider" name="tcProvider" disabled><br><br>
<label for="tcVenue">Venue:</label>
<input type="text" id="tcVenue" name="tcVenue" disabled><br><br>
<label for="tcFee">Fee:</label>
<input type="text" id="tcFee" name="tcFee" disabled><br><br>
<input type = "submit" value = "Schedule">
</form>
A snippet of the code that creates the table on a new page when Schedule
is pressed
$sql = "SELECT * FROM Training_Course WHERE tcDeleted = false AND tcStartDate > CURDATE()";
produceReport($sql);
function produceReport($sql){
$result = mysql_query($sql);
if($result === FALSE) {
die(mysql_error());
}
echo "<table><tr><th>Start Date</th><th>Number of Days</th><th>Start Time</th><th>End Time</th></tr>";
while ($row=mysql_fetch_array($result)){
echo "<tr align='center'>
<td>".$row['tcStartDate']."</td>
<td>".$row['tcLength']."</td>
<td>".$row['tcStartTime']."</td>
<td>".$row['tcEndTime']."</td>";
}
echo "</table>";
Any ideas please?
Dropdown list:
The table that is created:
As you can see, it displays information for 4 courses, instead of just the course I have selected in the drop-down list