Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.  
  5. <body>
  6.  
  7. <?php
  8. //=======================================================================
  9. $servername = "localhost";
  10. $username = "root";
  11. $password = "";
  12. $dbname = "courses";
  13. //========================================================================
  14. //========================================================================
  15. $conn = new mysqli($servername, $username, $password, $dbname);
  16. //========================================================================
  17. if ($conn->connect_error) {
  18. die("Connection failed: " . $conn->connect_error);
  19. }
  20. //========================================================================
  21.  
  22. $sql = "SELECT id, countries FROM countries";
  23. $result = $conn->query($sql);
  24.  
  25. if ($result->num_rows > 0) {
  26.  
  27. while($row = $result->fetch_assoc()) {
  28.  
  29. echo "<select>";
  30.  
  31. echo "<option value= ".$row["id"]."> ". $row["countries"]." </option>";
  32.  
  33. echo "</select>";
  34.  
  35. }
  36. } else {
  37. echo "0 results";
  38. }
  39.  
  40. //=============================================================================
  41.  
  42. $sql1 = "SELECT universities FROM universities where id = ' ".$row["id"]." '";
  43.  
  44. $result1 = $conn->query($sql1);
  45.  
  46.  
  47. if ($result1->num_rows > 0) {
  48.  
  49. while($row1 = $result1 -> fetch_assoc()) {
  50.  
  51.  
  52.  
  53. echo "<select>";
  54.  
  55. echo "<option value= > ". $row1["universities"]." </option>";
  56.  
  57. echo "</select>";
  58. }
  59. }
  60. //======================================================================================
  61.  
  62. $conn->close();
  63. //=======================================================================================
  64. ?>
  65.  
  66. </body>
  67.  
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement