Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "akademik";
- // Create connection
- $koneksi = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$koneksi) {
- die("Connection failed: " . mysqli_connect_error($koneksi));
- }
- $sql = "SELECT * FROM mahasiswa";
- $result = mysqli_query($koneksi, $sql) or die (mysqli_error($result));
- echo '<table border="5">';
- echo '<tr bgcolor="#006600">';
- echo '<td>Nim</td>';
- echo '<td>Nama</td>';
- echo '<td>Umur</td>';
- echo '<td>Gender</td>';
- echo '</tr>';
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>$row[0]</td>";
- echo "<td>$row[1]</td>";
- echo "<td>$row[2]</td>";
- echo "<td>$row[3]</td>";
- echo "</tr>";
- }
- mysqli_free_result($result);
- } else {
- echo "0 results".mysqli_error($result);
- }
- //mysqli_close($koneksi);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement