Created
July 3, 2024 11:43
-
-
Save untillnesss/956688c1c9a876b0af33011df75d318d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', '1'); | |
/* Attempt MySQL server connection. Assuming you are running MySQL | |
server with default setting (user 'root' with no password) */ | |
$link = mysqli_connect("192.168.1.7", "said", "saidsaid", "unirow"); | |
// Check connection | |
if($link === false){ | |
die("ERROR: Could not connect. " . mysqli_connect_error()); | |
} | |
// Attempt select query execution | |
$sql = "SELECT * FROM mahasiswa"; | |
if($result = mysqli_query($link, $sql)){ | |
if(mysqli_num_rows($result) > 0){ | |
echo "<table>"; | |
echo "<tr>"; | |
echo "<th>Nama</th>"; | |
echo "<th>NPM</th>"; | |
echo "</tr>"; | |
while($row = mysqli_fetch_array($result)){ | |
echo "<tr>"; | |
echo "<td>" . $row['name'] . "</td>"; | |
echo "<td>" . $row['npm'] . "</td>"; | |
echo "</tr>"; | |
} | |
echo "</table>"; | |
// Free result set | |
mysqli_free_result($result); | |
} else{ | |
echo "No records matching your query were found."; | |
} | |
} else{ | |
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); | |
} | |
// Close connection | |
mysqli_close($link); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment