Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>stuff older than 3 days</title>
- <link rel="stylesheet" type="text/css" href="style.php"/>
- </head>
- <body>
- <?php
- /*
- * Comments here
- */
- $serverName = "192.168.0.90";
- $databaseName = "";
- $dbUsername = "xxdbuserxx";
- $dbUserpass = "xxdbpassxx";
- $db_Name_Array = parse_ini_file("dbname.ini");
- $db_Srv_Array = parse_ini_file("srvname.ini");
- $k=0;
- $countq=0;
- //Loop through each database listed in the ini file
- foreach($db_Name_Array as $section=>$values){
- //$databaseName=$section
- $connectionInfo = array("UID" => $dbUsername, "PWD" => $dbUserpass, "Database" => $section);
- $link = sqlsrv_connect($serverName, $connectionInfo);
- //read the array and print
- $sql = "SELECT Field1, Field2, Field3, Field4, Field5, Field6 from Table;
- //stmt1 is solely for retrieving the number of rows, unfortunately it cant be retrieved from the normal stmt query.
- $stmt1 = sqlsrv_query( $link, $sql, array(), array('Scrollable' => 'buffered'));
- //display the number of results in the case that there are too many to see on the screen
- $countq=sqlsrv_num_rows($stmt1);
- // now do the same query but for displaying them to the screen
- $stmt = sqlsrv_query( $link, $sql);
- echo "<h2>$values ----- ( # of sessions older then 3 days: $countq )</h2>";
- echo"<table class='table1'>";
- //set the Header
- echo"<tr class='qtop1'><td>field1</td><td>field2</td><td>Field3</td><td>Field4</td><td>Field5</td><td>Field6</td></tr>n";
- //loop through the results changing color of every other row to make it easier to read
- while ($row = sqlsrv_fetch_array($stmt)){
- if ( isset($k) and $k==0){
- echo"<tr class='d0'><td>{$row['Field1']}</td><td>{$row['Field2']}</td><td>{$row['Field3']}</td><td>{$row['Field4']}</td><td>{$row['Field5']}</td><td>{$row['Field6']}</td></tr>n";
- $k=1;
- }
- else{
- echo"<tr class='d1'><td>{$row['Field1']}</td><td>{$row['Field2']}</td><td>{$row['Field3']}</td><td>{$row['Field4']}</td><td>{$row['Field5']}</td><td>{$row['Field6']}</td></tr>n";
- $k=0;
- }
- }
- echo"</table>";
- if( $stmt === false ){
- die( print_r( sqlsrv_errors(), true));
- }
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment