Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.05 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <h1> "working" </h1>
  5. <script type="text/javascript">
  6.     <?php
  7.         $myServer = "localhost";
  8.         $myUser = "root";
  9.         $myPass = "root";
  10.         $myDB = "Stocks";
  11.  
  12.         //connection to the database
  13.         $dbhandle = mssql_connect($myServer,$myUser,$myPass)
  14.           or die("Couldn't connect to SQL Server on $myServer");
  15.  
  16.         //select a database to work with
  17.         $selected = mssql_select_db($myDB, $dbhandle)
  18.           or die("Couldn't open database $myDB");
  19.  
  20.         //declare the SQL statement that will query the database
  21.         $query = "SELECT TOP 10 [ticker]"
  22.         $query .= "FROM [Stocks].[dbo].[NASDAQ_20160314]";
  23.  
  24.         //execute the SQL query and return records
  25.         $result = mssql_query($query);
  26.  
  27.         $numRows = mssql_num_rows($result);
  28.         echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
  29.  
  30.         //display the results
  31.         while($row = mssql_fetch_array($result))
  32.         {
  33.           echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
  34.         }
  35.         //close the connection
  36.         mssql_close($dbhandle);
  37.     ?>
  38. </script>
  39. </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement