0
I’m recently practicing PHP and I know how to loop with While, but I wanted to limit this loop so as not to break a column of the site.
<?php
include_once 'conexao.php';
$sql = "select * from perfil";
$result = mysqli_query($con, $sql);
while ($row = mysqli_fetch_array($result)){
?>
<article class="novos-titulos">
<h3><a href="perfil.php?idperfil=<?php echo $row["idperfil"];?>"><?php echo mb_strimwidth($row["titulo"], 0, 20, "..." ); ?></a></h3>
<a href="perfil.php?idperfil=<?php echo $row["idperfil"];?>"><img src="img/<?php echo $row["capa"]; ?>" alt=""></a>
<span>Total: <?php echo $row["episodios"]; ?></span>
</article>
<?php } mysqli_close($con);?>
</div>
What you want is to put a stop point on the correct loop? You can create a Count variable to stop the loop or use a for (https://www.w3schools.com/php/php_looping_for.asp)
– rodrigorf
if($Count == 10) break;
– rodrigorf
So. I want it to stop adding item to column. Limit to 5 items.
– OliverDamon
How so columns? The code does not generate several <Articles> one below the other?
– rodrigorf