HamburgIsNice
HamburgIsNice

Reputation: 105

How to get all entries out of a table?

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

Answers (2)

Pampy
Pampy

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

durbnpoisn
durbnpoisn

Reputation: 4669

Wrap it in a while loop. That way it will keep going until the end. An IF only runs once.

Upvotes: 0

Related Questions