<?php
$schoolclass=$_POST["schoolclass"];
if($schoolclass!=""){$class_out="where schoolclass='$schoolclass'";}else{$class_out="";}
echo "
<input type='text' list='stdname' name='stdname' class='form-control' placeholder='Student Name or ID'>
<datalist id='stdname'>";

include("connect.php");
$result_child=$dbh->query("select cid,fname,sname from children $class_out");
$row_child=$result_child->fetchObject();
$count_child=$result_child->rowCount();

if($count_child>0){
    do{
echo "<option value='".$row_child->cid." - ".$row_child->fname." ".$row_child->sname."'>";
    }while($row_child=$result_child->fetchObject());
}

echo "</datalist>";
?>