I am building a project on student attendance management. I am stuck at one feature. At the time when teacher wants to mark attendance of a class, he/she must fill a form about class details and subject details. What I want is to show only those classes to teacher, of which the subjects of class are assigned to the teacher. Classes are listed in a select box. The problem is occurring when more than one subjects of a class is assigned to a teacher. It show class more than once in the select box. I just want to show each class only once.
Here's my code of select box.
<div class="form-group">
<label for="class_id" class="control-label col-sm-2">Select Class Id :</label>
<div class="col-xs-10">
<select class="form-control" name="class_id" id="class_id">
<option selected="selected" value="">Select Class Id</option>
<?php
$q="select * from subjects where teacher_id='$_SESSION[teacher]'";
$res=mysqli_query($con,$q);
while($row=mysqli_fetch_array($res)){
echo "<option class='form-control'>".$row['class_id']." </option>";
}
?>
</select>
</div>
</div>