I have the following code
$result_categorias = "SELECT * FROM categorias ORDER BY ordem ASC";
$resultado_categorias = mysqli_query($conn, $result_categorias);
$total_categorias = mysqli_num_rows($resultado_categorias);
$quantidade_pg = 3;
<div class="row">
<?php while($row_categorias = mysqli_fetch_assoc($resultado_categorias)){?>
<div class="col-md-6">
<article class="mr-categorias-single">
<div class="mr-categorias-img">
<img src="imagens/categorias/<?php echo $row_categorias['imagem']; ?>" width="360" alt="">
<div class="mr-categorias-single-content">
<a href="produtos.php?&id=<?php echo $row_categorias['id']; ?>">
<h3><?php echo $row_categorias["nome"]; ?></h3>
<span><?php echo $row_categorias["resumo"]; ?></span>
</a>
</div>
</div>
</article>
</div>
<?php } ?>
</div>
Pull the categories and display through the while, a total of 3 results according to $quantidade_pg=3;
The beginning of while I have the <div class="col-md-6">
that is in the css file with 33% width to divide the total into 3 columns.
But if you only have 2 categories on the page, I would like the width to automatically change to 50% if you have only 1 category displayed at 100%.
Is there any way to get php to give the result of the width according to the number of categories displayed in the while result?