summaryrefslogtreecommitdiff
path: root/automated/linux/lemp/html/select-record.php
diff options
context:
space:
mode:
Diffstat (limited to 'automated/linux/lemp/html/select-record.php')
-rw-r--r--automated/linux/lemp/html/select-record.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/automated/linux/lemp/html/select-record.php b/automated/linux/lemp/html/select-record.php
new file mode 100644
index 0000000..d67dc6e
--- /dev/null
+++ b/automated/linux/lemp/html/select-record.php
@@ -0,0 +1,26 @@
+<?php
+$servername = "localhost";
+$username = "root";
+$password = "lemptest";
+$dbname = "myDB";
+
+// Create connection
+$conn = new mysqli($servername, $username, $password, $dbname);
+// Check connection
+if ($conn->connect_error) {
+ die("Connection failed: " . $conn->connect_error);
+}
+
+$sql = "SELECT id, firstname, lastname FROM MyGuests";
+$result = $conn->query($sql);
+
+if ($result->num_rows > 0) {
+ // output data of each row
+ while($row = $result->fetch_assoc()) {
+ echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
+ }
+} else {
+ echo "0 results";
+}
+$conn->close();
+?>