Advertisement
Guest User

rawrxd

a guest
Nov 20th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title> </title>
  5. </head>
  6. <style type="text/css">
  7. table, tr, td, th {
  8. border:1px solid black;
  9. }
  10. </style>
  11. <body>
  12. <?php
  13.  
  14. $servername = "localhost";
  15. $username = "joostottens";
  16. $password = "";
  17.  
  18. try {
  19. $conn = new PDO("mysql:host=$servername;dbname=Cijferlijst", $username, $password);
  20. // set the PDO error mode to exception
  21. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  22. echo "";
  23. }
  24. catch(PDOException $e)
  25. {
  26. echo "Connection failed: " . $e->getMessage();
  27. }
  28. ?>
  29.  
  30. <form method="POST">
  31. <select name='voornaam'>
  32. <option value="">Alle leerlingen</option>
  33. <?php
  34. $sql = "select distinct voornaam from Leerling order by voornaam";
  35. $result = $conn->query($sql);
  36. foreach ($result as $row) {
  37. echo "<option value='". $row["voornaam"]. "' >". $row["voornaam"]. "</option>";
  38. }
  39. ?>
  40. </select>
  41. <input type='submit' name="toon" value="toon">
  42. </form>
  43.  
  44. <table>
  45. <th>id</th><th>voornaam</th><th>achternaam</th><th>emailadres</th><th>klas</th><th>id</th><th>vak</th><th>leerling id</th><th>cijfer</th>
  46.  
  47. <?php
  48.  
  49. if (isset($_POST['toon']) and $_POST["voornaam"] != "") {
  50. $sql = "select * from Leerling INNER JOIN Cijfer2 ON Leerling.id = Cijfer2.Leerling_id where voornaam = '". $_POST["voornaam"]. "'";
  51. }
  52. else {
  53. $sql="SELECT * FROM Leerling INNER JOIN Cijfer2 ON Leerling.id = Cijfer2.leerling_id";
  54. }
  55. $result = $conn->query($sql);
  56. foreach ($result as $row){
  57. echo "<tr>";
  58. echo "<td>" . $row["leerling_id"]. "</td>";
  59. echo "<td>" . $row["voornaam"]. "</td>";
  60. echo "<td>" . $row["achternaam"]. "</td>";
  61. echo "<td>" . $row["emailadres"]. "</td>";
  62. echo "<td>" . $row["klas"]. "</td>";
  63. echo "<td>" . $row["id"]. "</td>";
  64. echo "<td>" . $row["vak"]. "</td>";
  65. echo "<td>" . $row["leerling_id"]. "</td>";
  66. echo "<td>" . $row["cijfer"]. "</td>";
  67.  
  68. }
  69.  
  70. ?>
  71. </table>
  72. </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement