PHP looping problem?
<p>I have this script that displays a max of 5 images for each row, but for some reason my <code>&lt;ul&gt;</code> tag won't close correctly if the number of items isn't an exact multiple of 5. How can I correct this problem so the <code>&lt;ul&gt;</code> tag will close even if the number of listed images is less then 5?</p>

<p>Here is my PHP code.</p>

<pre><code>if (!$dbc) {
    print mysqli_error($mysqli);
} else {
    $row_count = 0;
    while($row = mysqli_fetch_array($dbc)){ 
        if($row_count % 5 == 0){
         echo "&lt;ul&gt;";
        }
       echo "&lt;li&gt;&lt;a href='" .$row["url"]. "' title='".$row['title']."'&gt;";
        echo "&lt;img src='".$row['src']."'&gt;&lt;/a&gt;&lt;/li&gt;";
       if($row_count % 5 == 4) {
         echo "&lt;/ul&gt;";
       }
       $row_count++;
    }

}
</code></pre>
