Hello. There is a markup, like:
<div class="row-4"> тут 4 пункта из базы </div> <div class="row-4"> тут 4 пункта из базы </div> There is an indefinite number of points in the database, I need to open the block <div class="row-4"> before every fourth first point, and after 4 points, close </div> .
It is also necessary to take into account that in the last block there may be points less than 4.
I tried this:
<? $sp = 0; $table_all = mysql_query("SELECT * FROM `table` ORDER BY `id` DESC"); while ($table = mysql_fetch_assoc($table_all)) { $sp++; ?> <? if ($sp == 4) { ?> <div class="row-4"> <? } ?> <div> <input type="checkbox" class="checkbox" id="checkbox-<?=$table['id'];?>" name="<?=$table['id'];?>" /> <label for="checkbox-<?=$table['id'];?>"><?=$table['name'];?></label> </div> <? if ($sp == 4) { ?> </div> <? $sp = 0; } ?> <? } ?> But something I confuse apparently. I would be grateful for the help.
<div class="row-4">and final</div>and inside make a loop of output elements. and when($idx + 1) % 4 == 0then output intermediate</div><div class="row-4">- teranmysql_* apiremind you thatmysql_* apioutdated and cut from modern php versions. If you can, go topdo/mysqli- vp_arth