This is an example of using php to quickly deploy SQL Server reports.
This relies on the Microsoft SQL Server Driver for PHP and uses the W3 CSS framework and jQuery Datatables to display data in a useful way.
This example has been designed to be run on an internal network using folder-based security. The SQL credentials are stored in the file sql-login.php
and should include server, database, and user information with read-only permissions for the database.
The example.php
file shows how this works.
- Set the
$title
variable (page title and name) - Set the html form to take the input you need
- Set the php
$_GET
to pull the input into variables - Pass variables into a parameterized query within the
$params
array - Accept parameters into sql variables
- Use variables within the
where
clause to display the information you need
The php is meant to use the sql variable names as column names and display the result set as a datatable.