vendredi 29 juin 2018

Check for something in database within a echo tag

I'm using a while loop to echo out the users that are in the database in a table. Now, I want to check if the column "loggedin" is set to 1 (and if so, I want to put something with online after the name). This is my code:

<tr>
          <th>Name</th>
          <th>Date</th>
          <th>Actions</th>
        </tr>
        <?php
        while($row = mysqli_fetch_array($resultUsers))
        {
          echo "<tr>";
            echo "<td>" . $row['name'] . "</td>";
            echo "<td>" . $row['date'] . "</td>";
            echo "<td><a class='btn btn-default' href='member.php?user=" . $row['id'] . "'>Bekijk</a> <a class='btn btn-default' href='member.php?user=" . $row['id'] . "&sendrequest=1s'>Stuur vriendschapsverzoek</a></td>";
          echo "</tr>";
        }
        ?>

Now, I want to add some sort of code that checks if the user is online. Like this:

echo "<td>" . $row['name'] . "" . if($row['loggedin'] === 1) {"<p>Online</p>"} . "</td>";

Aucun commentaire:

Enregistrer un commentaire