Advertisement
idotherest34

while loop

Apr 10th, 2021
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.   <head>
  4.     <meta charset = "utf-8"/>
  5.     <title>Northwind Database - itins3</title>
  6.   </head>
  7.   <body>
  8.     <h1>Northwind Database - Orders Table</h1>
  9.     <hr/>
  10.     <?php
  11.  
  12.       // Connect to itins3 database
  13.       // use your username as the second parameter instead of crice
  14.       // use your password, instead of the constant DB_PASSWORD, it will be something like
  15.       // 's1234567'
  16.       $databaseConnection = mysqli_connect('itins3.madisoncollege.edu', 'skatz', 's2813455', 'Northwind');
  17.       // server addressm, username, password, database name
  18.  
  19.       // Test the database connection
  20.       if (!$databaseConnection)
  21.       {
  22.         exit("Connection failed. " . $databaseConnection);
  23.       }
  24.     ?>
  25.     <h2>Orders</h2>
  26.     <table border = '1'>
  27.       <tr>
  28.         <th>Order ID</th>
  29.         <th>Customer ID</th>
  30.         <th>Employee ID</th>
  31.         <th>Order Date</th>
  32.         <th>Ship Name</th>
  33.         <th>Ship Via</th>
  34.         <th>Freight</th>
  35.       </tr>
  36.       <?php
  37.         // Create SQL Statement
  38.         $sqlQuery = "SELECT * FROM Orders ORDER BY EmployeeID";
  39.         $resultSet = mysqli_query($databaseConnection, $sqlQuery);
  40.  
  41.         if (!$resultSet)
  42.         {
  43.           exit ("SQL Statement Error: " . $sqlQuery);
  44.         }
  45.  
  46.         while ($row = mysqli_fetch_array($resultSet))
  47.         {
  48.           echo "<tr>";
  49.           echo "<td>" . $row['OrderID'] . "</td>";
  50.           echo "<td>" . $row['CustomerID'] . "</td>";
  51.           echo "<td>" . $row['EmployeeID'] . "</td>";
  52.           echo "<td>" . $row['OrderDate'] . "</td>";
  53.           echo "<td>" . $row['ShipName'] . "</td>";
  54.           echo "<td>" . $row['ShipVia'] . "</td>";
  55.           echo "<td>" . $row['Freight'] . "</td>";
  56.           echo "</tr>";
  57.         }
  58.  
  59.         mysqli_close($databaseConnection);
  60.       ?>
  61.     </table>
  62.   </body>
  63. </html>
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement