What common mistake is the user making in their PHP code that is preventing data from being displayed from the database?

The user is not fetching the data from the database after executing the query. To display data from the database, the user needs to fetch the results using a method like `mysqli_fetch_assoc()` or `mysqli_fetch_array()` after executing the query.

// Connect to database
$conn = mysqli_connect("localhost", "username", "password", "database");

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// SQL query
$sql = "SELECT * FROM table_name";
$result = mysqli_query($conn, $sql);

// Fetch data and display
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        echo "ID: " . $row["id"] . " - Name: " . $row["name"] . "<br>";
    }
} else {
    echo "0 results";
}

// Close connection
mysqli_close($conn);