3
I’m creating a simple, photographic website, and I’m doing all the object-oriented PHP. 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, but I would like to know how to handle the query result in the best possible way.
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 how I’m treating 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 names 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 !
Thanks for the help !
– anuseranother
@anuseranother Dispo.
– Ricardo