.content .articles { display:flex; display: -webkit-flex; } .content .articles article{ max-width:40%; margin:1%; min-height:300px; } <div class="articles"> <article> <?php for ($i = 0; $i < count($news); $i++) { echo ' <img src="img/'.$news[$i]["id"].'.jpg" alt="" title=""> <h2>'.$news[$i]["title"].'</h2> <p>'.$news[$i]["text"].'</p> <h5>'.$news[$i]["date"].'</h5> <a href="article1" title=""> Читать далее</a> ' ;} ?> </article> </div> How to display news from the database in different blocks? I bring the news and in the end it turns out that they are on top of each other in the same css block, and I need them to be in separate blocks.
<?php require_once "connect.php"; function getNews ($limit) { global $mysqli; connectDB(); $result = $mysqli->query("SELECT*FROM `news` ORDER BY `id` DESC LIMIT $limit"); closeDB(); return resultToArray($result); } function resultToArray($result) { $array = array(); while(($row = $result->fetch_assoc()) != false) $array[]=$row; return $array; } ?>