-1
How to better optimize connection script and listing information from MySQL
? Because I check in my researches several ways to do this, but I do not know if this is a correct practice both of connection to database and to list information from MySQL
.
php connection.
<?php
$con = mysqli_connect("localhost", "root", "", "guaraparivirtual");
?>
index php.
<?php include ("conexao.php"); ?>
<?php
$seleciona=mysqli_query($con,"select * from noticias");
while($campo=mysqli_fetch_array($seleciona)){
?>
<?php echo $campo["Titulo"]."</br>"; ?>
<?php
}
?>
select id, titulo from noticias
and prints a link with the code(id) of the news and the title,<a href=\"noticia/$campo["id"]\" target="_blank">$campo["titulo"]</a><br/>
, unless your title contains no special characters. Note tag <br>.– Edilson
Define passwords directly in the code, the way it is in the
conexao.php
is not ideal, there are other ways, I specifically talked about one of the other ways here. About query optimization @Leo Caracciolo’s reply mentions one of the improvements that can be made, which is to avoid using the*
.– Inkeliz