I'm creating a simple website, for photography, and I'm doing all of PHP object-oriented. I know PHP procedural, but I would like to mix PHP with HTML as little as possible. My connection and my query are running perfectly, however I would like to know how to treat the query result as best as possible.
My function for the query:
function consultarDados($query){
$conexao = mysql_connect($this->host, $this->usuario, $this->senha);
mysql_select_db($this->banco, $conexao);
$rs = mysql_query($query, $conexao);
return $rs;
mysql_close($conexao);
}
And as I'm dealing with it on the index.php page:
include 'connectDB.php';
$conexao = new connectDb();
$retorno = $conexao->consultarDados('select * from slides');
if(mysql_num_rows($retorno) > 0){
while($row = mysql_fetch_assoc($retorno)){
echo $row ['imagem'];//esta parte eu fiz apenas para verificar se os resultados da query estão sendo obtidos de maneira correta.
}
}
I need to insert the query result into the image name of this piece of HTML:
<img src="img/slide_1.jpg" class="img-slide ativa">
<img src="img/slide_2.jpg" class="img-slide">
<img src="img/slide_3.jpg" class="img-slide">
Thank you!