Reputation: 105
I'd like to build a ul by pull the content out of a SQL table. But this code does only gives me the first row. What would be the best solution to get all 10 entries?
$query = "SELECT * FROM `activitys`";
echo '<td><ul>';
if ($result = mysqli_query($link, $query)) {
$row = mysqli_fetch_array($result);
echo "<li>".$row['content']."</li>";
}
echo '<td><ul>';
Upvotes: 0
Views: 144
Reputation: 979
You need to put it in a loop, like this:
while($row = mysqli_fetch_array($result)) {
echo "<li>".$row['content']."</li>";
}
Upvotes: 1
Reputation: 4669
Wrap it in a while loop. That way it will keep going until the end. An IF only runs once.
Upvotes: 0