I'm making a student details html page.I have a student details in a table and if their supervisor has been not selected, a supervisor drop down should appear in supervisor column.if they have selected their supervisor previously drop down will not appear and the supervisor's name will show. My problem is how to display only a drop down within a form element without submit button and as soon as select an option it should assign into a POST method.I'm using PHP OOP concepts.This is details table
if(isset($_SESSION['student'])){
$student=unserialize($_SESSION['student']);
echo "<div class=container>";
echo "<div class=details>";
echo "<table>";
echo "<tr>";
echo "<td>Student Name</td>";
echo "<td>".$student->getStudentName()." ".$student->getStudentSurname()."</td>";
echo "</tr>";
echo "<td>Supervisor</td>>";
echo "<td>";
if($student->getSupervisor()!=null){
$student->selectSupervisor();
}else{
$student->getSupervisor();
}
echo "</td>";
echo "<td>";
echo "<tr>";
echo "</tr>";
echo "</table>";
echo "</table>";
echo "</div>";
echo "</div>";
}
This is Student class
public function setSupervisor()
{
if(isset($_POST['supervisor'])){
$this->supervisor = $_POST['supervisor'];
}
}
//Select Supervisor function
function selectSupervisor(){
echo "<form action='Supervisee.php' method='post'>";
echo "<select name='supervisor'>";
$query = $handler->query("SELECT Lecturer_name FROM lecturer");
while($row = $query->fetch()){
echo "<option value='".$row['Lecturer_name']."'>".$row['Lecturer_name']."</option>";
}
echo "</select>";
echo "</form>";
}