1
I’m trying a big problem some time, where I try to get the next item of an array, coming from a BD, but it doesn’t work. The goal is to pass a slide with different images of registered users in a BD.
<div class="container">
<div class="section-heading center-holder">
<h2>Alguns de nossos clientes</h2>
<div class="section-heading-line"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod<br>tempor incididunt ut labore et
dolore magna aliqua.</p>
</div>
<div class="row mt-60">
<ul class="slider">
<?php
$control_active = 2;
$cont = 1;
$users = "SELECT id_usuario, slug, nome, foto, email, views, table_status
FROM usuarios
WHERE table_status = 1
AND foto <> ''
AND views > 500
AND slug NOT IN ('sergiomm')
AND slug NOT LIKE '%dieta%'";
$conn = new conexao();
$consulta = $conn->consulta($users);
$result = $conn->busca($consulta);
$total = $conn->conta($consulta);
if ($total > 3){
while ($row = $conn->busca($consulta)){
$linkInicial = 'http://linkto.bio/';
$linkFinal = str_replace('|:|', '', $row['foto']);
$linkCompleto = $linkInicial . $linkFinal;
if($control_active == 2){
?>
<li>
<input type="radio" id="slide<? echo $cont; ?>" name="slide" checked>
<img src="<? echo $linkCompleto; ?>" alt="<? echo $row['slug']; ?>"/>
<img src="<? echo $linkCompleto; ?>" alt="<? echo $row['slug']; ?>"/>
<img src="<? echo $linkCompleto; ?>" alt="<? echo $row['slug']; ?>"/>
<img src="<? echo $linkCompleto; ?>" alt="<? echo $row['slug']; ?>"/>
<label for="slide<? echo $cont; ?>"></label>
</li>
<?php
$control_active = 1;
}else{
?>
<? } $cont += 1; } } ?>
</ul>
</div>
</div>
<br/><br/><br/>
<!-- /Nossos usuários -->
I wanted you on the line <img src="<? echo $linkCompleto; ?>" alt="<? echo $row['slug']; ?>"/>
take the later images.
Can someone help me figure this out.
For each row you want to pick up all the later lines?
– dm707
Yes, the first beauty, she does it right, takes the first item, but the other 3 lines repeat the same data.
– Moises Fausto
I tried with next(), and with for also.
– Moises Fausto
First, is the image saved in a server directory? According to the field exists in the database? Could you post the full PHP code?
– Nicolas Pereira
Yes, Nicolas. The image exists and so does the field.
– Moises Fausto
@Nicolaspereira I edited with the complete code.
– Moises Fausto
@Is this working? Are you returning something already pro $Row? I didn’t understand your question
– Nicolas Pereira
Yes @Nicolaspereira, it returns the data from SELECT, I treat this data and take the image, passing from $Row['photo'] to the variable. This works "perfectly" for the first item, but I want to know how I get the next image (that exists!), for the next item.
– Moises Fausto