Guest User

Untitled

a guest
Apr 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. $serverName = "TestDB,1433"; //serverNameinstanceName
  2. $connectionInfo = array( "Database"=>"Database123", "UID"=>"sa", "PWD"=>"Pass.124");
  3. $conn = sqlsrv_connect( $serverName, $connectionInfo);
  4.  
  5. if( $conn ) {
  6. echo "Connection established.<br />";
  7. }
  8. else{
  9. echo "Connection could not be established.<br />";
  10. die( print_r( sqlsrv_errors(), true));
  11. }
  12. $sql="SELECT * from [Database123].[dbo].[LOG] ";
  13. $stmt=sqlsrv_query($conn,$sql);
  14. if ($stmt===false){
  15. die(print_r(sqlsrv_errors(), true));
  16. }
  17.  
  18. echo "<table border='1'>
  19. <table class='table'>
  20.  
  21. <thead>
  22. <tr>
  23. <th class='w'>Logon User</th>
  24. <th>Server Received Log Time</th>
  25. </tr>
  26. </thead>";
  27.  
  28. while ($row =sqlsrv_fetch_Array($stmt,SQLSRV_FETCH_BOTH))
  29. {
  30. echo"<tbody>";
  31. echo"<tr>";
  32. echo"<td>".$row['基準日時']."</td>";
  33. //echo"<td>".$row['[基準日時]']->format('Y-m-d h-m-s')."</td>";
  34. echo"</tr>";
  35. echo"</tbody>";
  36. }
  37. echo"</table>";
  38.  
  39. sqlsrv_close($conn);
  40. ?>
Add Comment
Please, Sign In to add comment