So I have a code in PHP to display MySQL database information. This is the PHP code:
<?php
$servidor = mysqli_connect ("localhost","root","");
mysqli_select_db($servidor, "produtos");
if (isset($_GET['texto'])) {
$pesquisa = $_GET['texto'];
$query = mysqli_query($servidor, "SELECT * FROM produtos WHERE Nome LIKE '%$pesquisa%' OR Referencia LIKE '%$pesquisa%'");
if(mysqli_num_rows($query) > 0) {
while($resultados = mysqli_fetch_array($query)) {
echo "<h3>Nome: ".$resultados['Nome']."</h3>Referência: ".$resultados['Referencia']."";
}
} else {
echo "<h3>Não foram encontrados resultados!</h3>";
}
}
?>
But right now, that information is displayed in one single line, like this:
and I want to display it in rows, like this:
How can I do this in PHP?
Thank you


mysqliyou should be using parameterized queries andbind_paramto add user data to your query. DO NOT use string interpolation or concatenation to accomplish this because you have created a severe SQL injection bug. NEVER put$_POST,$_GETor any user data directly into a query, it can be very harmful if someone seeks to exploit your mistake.mysqliis significantly less verbose, making code easier to read and audit, and is not easily confused with the obsoletemysql_queryinterface. Before you get too invested in the procedural style it’s worth switching over. Example:$db = new mysqli(…)and$db->prepare("…")The procedural interface is an artifact from the PHP 4 era whenmysqliAPI was introduced and should not be used in new code.