Shea Lavington Shea Lavington - 9 months ago 14
SQL Question

Displaying information from a database cell

Okay, so I'm trying to create an SQL that will run when the page loads, I ahve this, however it's not returning correctly, I need it so when returned, if cell "player_presenter" is empty then do nothing, and if it is full then display the information in it, however it's always displaying as "Full".

It is connected to the database and running properly, I think it's my if function, still learning haha.


include 'database.php';
$conn = new mysqli($servername, $username, $password, $dbname);
$result = $conn->query("SELECT * FROM player_table WHERE id = 1");

if ($result->num_rows > 0)

{echo 'Empty';}

{echo 'Full'; }



Use this:

if ($result->num_rows > 0) 
    while($row = $result->fetch_assoc()) {

        if(empty($row['player_presenter'])) {
            echo 'Empty';
        } else { 
            echo 'Full';