What changes can be made to the PHP code to display all rows from the database?

To display all rows from the database, you can modify the SQL query in the PHP code to select all rows from the database table. This can be done by removing any specific conditions or filters in the WHERE clause of the query. By doing so, the query will retrieve all rows from the table and display them on the webpage.

<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Select all rows from the database table
$sql = "SELECT * FROM table_name";
$result = $conn->query($sql);

// Display the rows
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "Column1: " . $row["column1"]. " - Column2: " . $row["column2"]. "<br>";
    }
} else {
    echo "0 results";
}

$conn->close();
?>