diff --git a/LGM/db.php b/LGM/db.php new file mode 100644 index 0000000000000000000000000000000000000000..009b4612a37d82f9b90a9e7a0a31af1c38c6150d --- /dev/null +++ b/LGM/db.php @@ -0,0 +1,21 @@ +<?php + + function connect() { + $conn = new mysqli("localhost", "root", "", "LGM"); + if ($conn->connect_error) { + die($conn->connect_error); + } + echo "Connected<br>"; + return $conn; + } + + function close($conn) { + $conn->close(); + echo "Closed<br>"; + } + + function query($conn, $sql) { + return $conn->query($sql); + } + +?> \ No newline at end of file diff --git a/LGM/index.php b/LGM/index.php index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..da3199f3bfe1f473f7d4eb225a46c5c2e65fd27c 100644 --- a/LGM/index.php +++ b/LGM/index.php @@ -0,0 +1,13 @@ +<?php + + include 'db.php'; + + $conn = connect(); + $data = query($conn, "SELECT * FROM coba"); + while ($row = $data->fetch_assoc()) { + echo "Id : ".$row["id"]." - Teks: ".$row["teks"]."<br>"; + } + query($conn, "DELETE FROM coba WHERE id=2"); + close($conn); + +?> \ No newline at end of file