0

How is the condition in while loop working here?

<?php include'database.php'; ?> <?php $query="SELECT * FROM info"; $shout=mysqli_query($con,$query); ?> <?php while($row=mysqli_fetch_assoc($shout)): ?> <li class="shout"> <?php echo $row['time'] ?> <?php echo $row['user'] ?> <?php echo $row['message'] ?> </li> <?php endwhile; ?>

8th Nov 2017, 4:09 PM
saleheen
saleheen - avatar
2 ответов
+ 3
mysqli_fetch_assoc() will return either the next row as an associative array or NULL if there is none. If the assignment is successful to an object it is truthy, when it is NULL it is equivalent to false. https://stackoverflow.com/questions/6741399/can-i-define-a-variable-in-a-php-if-condition https://stackoverflow.com/questions/137487/null-vs-false-vs-0-in-php
8th Nov 2017, 4:35 PM
ChaoticDawg
ChaoticDawg - avatar
+ 4
It's looping so long as there is still another row to read from.
8th Nov 2017, 4:24 PM
AgentSmith