0
I’m using this code below working perfect with an image loop coming from the BD.
<div align="center" u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 600px; height: 300px; overflow: hidden;">
<?php
include "conexao.php";
$imagem = $_POST['imagem'];
$texto = $_POST['texto'];
$query = mysql_query("SELECT * FROM banner ORDER BY RAND() LIMIT 4");
while($res = mysql_fetch_array($query)){
?>
<div>
<img src="img_banner/<?php echo $res['imagem']; ?>" alt="image slider" />
<div u=caption t="*" class="captionOrange_" style="position:absolute; left:20px; top: 30px; width:300px; height:30px;">
<?php echo $res['texto']; ?>
</div>
</div>
<?php } ?>
</div>
However I am trying to create a simulator and I would like to adapt this above loop to work in the code below that is bringing the images of $_SESSION.
<div align="center" u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 600px; height: 300px; overflow: hidden;">
<?php
// Inicio da Sessão do Banner das páginas menu
@session_start();
if(!isset($_SESSION['banner'])){ // Se a Session não for iniciada
$img01 = 'img_banner/01.png'; // Carrega esse conteúdo
$img02 = 'img_banner/02.png'; // Carrega esse conteúdo
$img03 = 'img_banner/03.png'; // Carrega esse conteúdo
$img04 = 'img_banner/04.png'; // Carrega esse conteúdo
$img05 = 'img_banner/05.png'; // Carrega esse conteúdo
$img06 = 'img_banner/06.png'; // Carrega esse conteúdo
$img07 = 'img_banner/07.png'; // Carrega esse conteúdo
}else{ // Se não
if(isset($_SESSION)) { // Se a Session for iniciada
$img01 = ''.$_SESSION['banner'].''; // Carrega esse conteúdo
}}
?>
<div>
<img src="<?php echo $img01 ?>" alt="image slider" />
</div>
<div>
<img src="<?php echo $img02 ?>" alt="image slider" />
</div>
<div>
<img src="<?php echo $img03 ?>" alt="image slider" />
</div>
<div>
<img src="<?php echo $img04 ?>" alt="image slider" />
</div>
<div>
<img src="<?php echo $img05 ?>" alt="image slider" />
</div>
<div>
<img src="<?php echo $img06 ?>" alt="image slider" />
</div>
<div>
<img src="<?php echo $img07 ?>" alt="image slider" />
</div>
</div>
But I’m not sure how to build the loop to work, or even if there’s a way to make it work that way. Looping images from $_SESSION.
If friends can give me a light, I’d be grateful.
To view the banner working with the images coming from $_SESSION, go to: www.simuleseusite.com
Hugs to all.
Hello Miguel, but once I do not understand your reasoning, because you tell me to make the first code and then have me replace everything including the first code? I don’t get it... And Voce talks about looking for the images in the BD, but I don’t want access to the BD, because the initial images are already inserted in SESSION as img01, 02.... It would be possible to assemble this code so that it works with your reasoning, based on the data I passed, but without using the connection with the BD of how it works at the address (http://www.simuleseusite.com/).
– Murilo Cabral
Basically it is if you do not insert in Session the images will have to fetch them from the BD again to have them available in the Prox instead. I put some explanations in comment
– Miguel
OK, but I tried a lot of ways to build the code and without success. ?
– Murilo Cabral
What’s the mistake that comes?
– Miguel
I’ll publish the page on the server so you. see what’s going on, thanks?
– Murilo Cabral
This last key should not be closed with
<?php }} ?>
– Murilo Cabral
I published closing the last key. See the result on (http://www.simuleseusite.com/).
– Murilo Cabral
See how the code turned out in my reply:
– Murilo Cabral
Not to see anything like this in php. There are some in javascript as well
– Miguel
Let’s go continue this discussion in chat.
– Murilo Cabral