S
S
Stas2015-11-13 16:53:04
PHP
Stas, 2015-11-13 16:53:04

How to make the hr tag inserted after a certain number of divs?

There is a page on which the divs go horizontally 4 pieces in a row, I would like the hr tag to be inserted every 4
In PHP I just started to swim so don’t swear too much, I managed to add one hr after 4 divs, and for some reason the next hr is inserted through every single div
here

<div id="wrapper">
<?php
$query_film = mysql_query("SELECT * FROM film ORDER BY id DESC") or die("ошибка");
while ($data_film = mysql_fetch_array($query_film)) {
    printf("<div class='films_block'>
        
        <a href='films_full.php?id=%s'><div class='img_films'>%s</div></a>
        <div class='link_title'><a href='films_full.php?id=%s'>%s</a></div>
        </div>",$data_film['id'],$data_film['img'], $data_film['id'], $data_film['title'] );
    $i = 4;
    $c = $data_film['id'];
    while ($i < $c) {
        echo "<hr>";
        break;
    }
}

?>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GreatRash, 2015-11-13
@GreatRash

if ($c % $i === 0) {
  echo "<hr>";
}

break is not clear why you have it, you don’t need to exit the loop?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question