-2
Hello. I’m making a website for student purposes, taking into account that the connection to the database is perfect, when it comes to getting the data stored in the database, PHP duplicates the content on the page. As in the following image (Ignore the image, because its url is the same for all):
[![s][1]][1]
<?php
$server ='localhost';
$user ='root';
$password ='root';
$dbname ='site_salgados';
$port ='3306';
$db_connect = new mysqli($server, $user, $password, $dbname, $port);
mysqli_set_charset($db_connect, "utf8");
if ($db_connect->connect_error == true) {
echo 'Falha ao se conectar! erro: ' . $db_connect->connect_error;
} else {
$sql = "SELECT DISTINCT nome, descricao FROM produtos";
$result = $db_connect->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$nome = $row['nome'];
$descricao = $row['descricao']; ?>
<div class="container mt-5 mb-4 ">
<div class="row">
<div class="col-md-6">
<div>
<a href="https://www.google.com"><img src="gallery/1.jpg"></a>
<h6><a href="#"><?php echo $nome; ?></a></h6>
<p><?php echo $descricao; ?></p>
</div>
</div>
<div class="col-md-6">
<div>
<a href="https://www.google.com"><img src="gallery/1.jpg"></a>
<h6><a href="#"><?php echo $nome; ?></a></h6>
<p><?php echo $descricao; ?></p>
</div>
</div>
</div>
</div>
<?php }
}
}
?>
Could someone help me? I’ve been trying to solve this mistake for some time.
I’m using the CSS framework, Boostrap 4.
– João Victor