Advertisement
Guest User

Untitled

a guest
May 28th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. $username = "root";
  4. $password = "";
  5. $hostname = "localhost";
  6.  
  7. $dbname = "major_degrees";
  8. $str='';
  9.  
  10. // Create connection
  11. $conn = new mysqli($hostname, $username, $password, $dbname);
  12.  
  13. // Check connection
  14. if ($conn->connect_error) {
  15. die("Connection failed: " . $conn->connect_error);
  16. }
  17.  
  18. $sql = "SELECT degree_name FROM majors";
  19. $result = $conn->query($sql);
  20.  
  21. $out = '';
  22. $cnt = 0;
  23. if ($result->num_rows > 0) {
  24. // output data of each row
  25. while($row = $result->fetch_assoc()) {
  26. $cnt++;
  27. $out .= '<input id="cb_' .$cnt. '" class="someclass" type="checkbox" />' .$row['degree_name']. '<br/>';
  28. }
  29. echo $out;
  30. }
  31. $conn->close();
  32.  
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement