Search

Showing posts with label global. Show all posts
Showing posts with label global. Show all posts

Sunday, July 31, 2016

Dynamic php code to get database fields in sql server

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>' );
};

....
....
?>