File: /var/www/nclive/technc/get_entity.php
<?php
include_once 'config.php';
$id=$_REQUEST['id'];
$stmt = $db->prepare("SELECT link.entity_id,link.exam_id,entity.name FROM sp_exam_links as link left join sp_exam_entity as entity on entity.id=link.entity_id where link.exam_id='$id' group by link.entity_id order by entity.display_order asc");
$stmt->execute();
$select=$stmt->fetch(PDO::FETCH_ASSOC); ?>
<select class="js-select2 form-control entity" name="entity<?php echo $id; ?>" style="width: 100%;" >
<?php while($row=$stmt->fetch(PDO::FETCH_ASSOC)) { ?>
<option value="<?php echo $row['entity_id']; ?>"><?php echo $row['name']; ?></option>
<?php } ?>
</select>