Search

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

....
....
?>

Php1-Pass a variable from one page to other webpage

How to pass a variable from one webpage to another?

Its the simple command to be given in both the pages:


Mypage.php

<?php
session start();
row=1;
?>

Mypage1.php

<?php
session start ();
echo row;
?>