Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. $myServer = "localhost";
  3. $myUser = "sa";
  4. $myPass = "password1";
  5. $myDB = "testlink";
  6.  
  7. //connection to the database
  8. $dbhandle = mssql_connect($myServer, $myUser, $myPass)
  9. or die("Couldn't connect to SQL Server on $myServer");
  10.  
  11. //select a database to work with
  12. $selected = mssql_select_db($myDB, $dbhandle)
  13. or die("Couldn't open database $myDB");
  14.  
  15. //declare the SQL statement that will query the database
  16. $query = "SELECT * ";
  17. $query .= "FROM users";
  18.  
  19. //execute the SQL query and return records
  20. $result = mssql_query($query);
  21.  
  22. $numRows = mssql_num_rows($result);
  23. echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
  24.  
  25. //display the results
  26. while($row = mssql_fetch_array($result))
  27. { echo "<li>" . $row["FIRST_NAME"] . "</li>"; }
  28.  
  29. //close the connection
  30. mssql_close($dbhandle);
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement