Here is small code snippet to display php fields dynamically:
page.php
<?php
....
....
$sql = "SELECT * FROM xyz where student1 ='$user1'";
$stmt = sqlsrv_query($conn, $sql);
if( $stmt === false ) {
die( '<pre>'.print_r( sqlsrv_errors(), true).'</pre>' );
};
if( sqlsrv_fetch($stmt) === false ) {
die( '<pre>'.print_r( sqlsrv_errors(), true).'</pre>' );
};
....
....
?>