-
Notifications
You must be signed in to change notification settings - Fork 0
PHP Sample
David Culbreth edited this page Sep 27, 2017
·
3 revisions
The table will make a number of AJAX requests, and you can handle the data as you see fit, but this is one possible application for the file. Let's call this file my_query.php
for reference. You'll notice that this is the file that we reference on the page explaining how to use the JS PHPQueryTable object.
<?php
include ($_SERVER['DOCUMENT_ROOT'].'/path/to/json-encode.inc.php');
$serverName = "serverName\sqlexpress";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT * FROM Table_1 where ID = ?";
$params = array(1); //<-- selecting where Table1.ID is 1
$stmt = sqlsrv_query( $conn, $sql, $params);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
$data = sqlsrv_query_to_json($stmt);
echo $data;
?>