Guest User

Untitled

a guest
Mar 13th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>stuff older than 3 days</title>
  4. <link rel="stylesheet" type="text/css" href="style.php"/>
  5. </head>
  6. <body>
  7.  
  8. <?php
  9.  
  10. /*
  11. * Comments here
  12. */
  13. $serverName = "192.168.0.90";
  14. $databaseName = "";
  15. $dbUsername = "xxdbuserxx";
  16. $dbUserpass = "xxdbpassxx";
  17. $db_Name_Array = parse_ini_file("dbname.ini");
  18. $db_Srv_Array = parse_ini_file("srvname.ini");
  19. $k=0;
  20. $countq=0;
  21.  
  22. //Loop through each database listed in the ini file
  23. foreach($db_Name_Array as $section=>$values){
  24. //$databaseName=$section
  25.  
  26.  
  27. $connectionInfo = array("UID" => $dbUsername, "PWD" => $dbUserpass, "Database" => $section);
  28. $link = sqlsrv_connect($serverName, $connectionInfo);
  29. //read the array and print
  30. $sql = "SELECT Field1, Field2, Field3, Field4, Field5, Field6 from Table;
  31.  
  32. //stmt1 is solely for retrieving the number of rows, unfortunately it cant be retrieved from the normal stmt query.
  33.  
  34. $stmt1 = sqlsrv_query( $link, $sql, array(), array('Scrollable' => 'buffered'));
  35.  
  36. //display the number of results in the case that there are too many to see on the screen
  37. $countq=sqlsrv_num_rows($stmt1);
  38. // now do the same query but for displaying them to the screen
  39. $stmt = sqlsrv_query( $link, $sql);
  40. echo "<h2>$values ----- ( # of sessions older then 3 days: $countq )</h2>";
  41. echo"<table class='table1'>";
  42. //set the Header
  43.  
  44. echo"<tr class='qtop1'><td>field1</td><td>field2</td><td>Field3</td><td>Field4</td><td>Field5</td><td>Field6</td></tr>n";
  45.  
  46. //loop through the results changing color of every other row to make it easier to read
  47.  
  48. while ($row = sqlsrv_fetch_array($stmt)){
  49. if ( isset($k) and $k==0){
  50. 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";
  51. $k=1;
  52. }
  53. else{
  54. 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";
  55. $k=0;
  56. }
  57.  
  58. }
  59. echo"</table>";
  60. if( $stmt === false ){
  61. die( print_r( sqlsrv_errors(), true));
  62. }
  63. }
  64.  
  65. ?>
  66.  
  67. </body>
  68. </html>
Add Comment
Please, Sign In to add comment