-1

Im trying to make a table be displayed out into the browser i have added data to my database and used the following code include_once 'dbh.inc.php';

$list = "SELECT * FROM users";
$results = mysqli_query($conn, $list);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        echo "id: " . $row["id"]. " - listing: " . $row["address"]. " " . $row["type"]. "<br>";
    }
} else {
    echo "0 results";
}

but I always get 0 results, and no errors Im not sure what is wrong (the database is populated and there is a db connection).

1 Answers1

-2

I suppose this should be:

$list = "SELECT * FROM users";
$results = mysqli_query($conn, $list);

if (mysqli_num_rows($results) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($results)) {
        echo "id: " . $row["id"]. " - listing: " . $row["address"]. " " . $row["type"]. "<br>";
    }
} else {
    echo "0 results";
}
Jan Myszkier
  • 2,652
  • 1
  • 15
  • 23