I want to select the last row for my database and echo the columns titled s1 and s2 to the body of the web page, the following is my code. This gives an error.
<html>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mydb2";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT s1, s2 from reading ORDER BY id DESC LIMIT 1";
$row = array();
$row = mysqli_query($conn,$sql);
echo " cup 1". $row["s1"]. "CUP 2". $row["s2"];
?>
</body>
</html>
fetchpart, after the query execution, fetch the results