Created
May 24, 2020 15:26
-
-
Save dikiwidia/d685b0401d0de8299bd8858f773fa7cc to your computer and use it in GitHub Desktop.
Koneksi ke Database
This file contains hidden or 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 | |
$ip = "localhost"; | |
$username = "pma"; // default xampp "root" | |
$password = "admin123"; // default xampp "" | |
$database = "belajar"; | |
$conn = new mysqli($ip,$username,$password,$database); | |
if ($conn->connect_errno) { | |
echo "Failed to connect to MySQL: " . $conn->connect_error; | |
exit(); | |
} | |
?> |
This file contains hidden or 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 | |
include "koneksi.php"; | |
// Buat Query | |
$sql = "SELECT * FROM user"; | |
$query = $conn->query($sql); | |
// Looping Data | |
while($row = $query->fetch_array()){ | |
echo $row['nama']." (".$row['alamat'].") - JK:".$row['jenis_kelamin']; | |
echo "<br />"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment