Advertisement
Guest User

hw3_roni

a guest
Jun 7th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>DBMS - HW3 - 314639402 - 312237639</title>
  6.     <style>
  7.         .center{
  8.             display: block;
  9.             margin-left: auto;
  10.             margin-right: auto;
  11.             width: 30%;
  12.         }
  13.  
  14.         .textCenter{
  15.             text-align: center;
  16.         }
  17.     </style>
  18. </head>
  19. <body style="background-color: lightseagreen;text-align: center">
  20. <h1 style="text-align: center;font-family: 'Tahoma'">Welcome to the food survey</h1>
  21. <p style="text-align: center;">This is Yael Kiselman and Roni Zaitsev's site. More generic description to come.</p>
  22. <img src="img/eating.jpg" alt="We know how to alt tag in HTML!" class="center">
  23. <br>
  24. <a href="upload.php">Click here for form upload page</a> | <a href="fill.php" >Click here for form fill page</a>
  25. <?php
  26. $server = "tcp:techniondbcourse01.database.windows.net,1433";
  27. $user = "roniza";
  28. $pass = "Qwerty12!";
  29. $database = "roniza";
  30. $c = array("Database" => $database, "UID" => $user, "PWD" => $pass);
  31. sqlsrv_configure('WarningsReturnAsErrors', 0);
  32. $conn = sqlsrv_connect($server, $c);
  33. if($conn === false)
  34. {
  35.     echo "error";
  36.     die(print_r(sqlsrv_errors(), true));
  37. }
  38. //  echo "<center>";
  39. echo "<table class='center'>";
  40. echo "<tr><th>Sports</th><th>Average GPA</th><th>Average Weight</th></tr>";
  41. $sql = "SELECT sport , AVG (F.GPA) as Average GPA, AVG (F.weight) as Average Weight FROM Food WHERE F.coffee = 2 and F.comfort_food = 'chocolate' GROUP BY sport";
  42. $result=sqlsrv_query($conn,$sql);
  43. while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC))
  44. {
  45.     echo "<tr><td>".$row['sport']."</td><td>".$row['Average GPA']."</td><td>".$row['Average Weight']."</td></tr>";
  46.  
  47. }
  48. echo "</table>"
  49. //    echo "</center>";
  50. ?>
  51.  
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement