1$sql = "SELECT id, firstname, lastname FROM MyGuests";
2$result = $conn->query($sql);
3
4if ($result->num_rows > 0) {
5 // output data of each row
6 while($row = $result->fetch_assoc()) {
7 echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
8 }
9} else {
10 echo "0 results";
11}
12$conn->close();
1SELECT * FROM `table_name`;
2SELECT `col1`,`col2` FROM `table_name`;
3SELECT `col1 as name`,`col2 as email` FROM `table_name`;
4SELECT * FROM `table_name` WHERE id = '1';