Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = "root";
- $password = "";
- $hostname = "localhost";
- $dbname = "major_degrees";
- $str='';
- // Create connection
- $conn = new mysqli($hostname, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT degree_name FROM majors";
- $result = $conn->query($sql);
- $out = '';
- $cnt = 0;
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $cnt++;
- $out .= '<input id="cb_' .$cnt. '" class="someclass" type="checkbox" />' .$row['degree_name']. '<br/>';
- }
- echo $out;
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement