Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

brunobrobr1

Integração php com bootstrap

Recommended Posts

Boa noite galera tenho meu codigo php que lista meus baner no banco de dados bom ai eu fiz o download de um arquivo bootstrap de slid de imagens so que não estou conseguindo subistituir os arquivos da imagen pelo meu php para listar minhas imagens do banco de dados se vocês poderem me ajudar eu agradeço. meu codigo php e esté:

<?php
			require 'admin/conexao/conexao.php';
			$sql = mysql_query("SELECT * FROM baner");
			$rasc = "<div id='slideShow'>";
			while($linhas = mysql_fetch_array($sql)){
				// .= e um operador de atribuição ou seja esta atribuindo a variavel $rasc com a img 
			$rasc .= "<img src='admin/img_banner/".$linhas['caminho']."' width='1000' height='400' />";
			}
			$rasc .= "</div>";
			echo $rasc;
		?>

bom este e meu codigo php quero colocar ele aqui no lugar deste codigo do slid, veja que neste slid passa tres imagens, quero subistituir ele pelo meu php sem tirar o efeito de slid, segue meu codigo do slid.:

<div class="carousel-inner">
            <div class="item active">
                <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide One');"></div>
               
            </div>
            <div class="item">
                <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Two');"></div>
                
            </div>
            <div class="item">
                <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Three');"></div>
                
            </div>
        </div>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Beleza, mas qual é exatamente a dúvida?

 

Para usar o Bootstrap, lembre se respeitar a estrutura html/css dele. Sempre use as mesmas classes.

 

A div:

<div class="item active">
                <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide One');"></div>               
</div>

Ficaria dentro do seu while. E a sua div #slideShow, iria virar:

$rasc = "<div class="carousel-inner" id='slideShow'>";

Compartilhar este post


Link para o post
Compartilhar em outros sites

Aqui um exemplo de como fiz...

<?php
	$sql = "SELECT * FROM conteudo WHERE DESTAQUE='1' ORDER BY DATA DESC, ID DESC";
	
	$rs = $pdo->query($sql)->fetchAll();
	
	if (count($rs) > 0) {
?>
<div class="carousel slide carousel-v1" id="myCarousel-1">
    <div class="carousel-inner">
        <?php
			$i = 1;
			
			foreach ($rs as $row) {
				$id = $row["ID"];
				$titulo = utf8($row["TITULO"],1);
				$imagem = $row["DESTAQUE_IMAGEM"];
		?>
        <div class="item <?php if ($i == 1) {echo "active";} ?>">
			<a href="blog_conteudo.php?<?php echo $link_blog?>id=<?php echo $id; ?>">
            <img alt="" src="assets/img/sliders/<?php echo $imagem; ?>">
            </a>
			<div class="carousel-caption">
				<p><?php echo $titulo; ?></p>
			</div>
        </div>
		<?php
				$i++;
			}
		?>
    </div>
    
    <div class="carousel-arrow">
        <a data-slide="prev" href="#myCarousel-1" class="left carousel-control">
            <i class="fa fa-angle-left"></i>
        </a>
        <a data-slide="next" href="#myCarousel-1" class="right carousel-control">
            <i class="fa fa-angle-right"></i>
        </a>
    </div>
</div>
<?php
	}
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ola,
tempos depois....
estou com problema que semelhante mas não no carrousel...
o css não carrega, não é reconhecido no browser apesar de o código fonte da pagina estar montado corretamente:

o php:

<?php
$sql='SELECT * FROM blog_posts ORDER BY postID DESC';
$result = mysqli_query ($conn, $sql);
while ($row = mysqli_fetch_array($result)) {
$titulo = $row['postTitle'];
$subtitulo = $row['postDesc'];
$conteudo = $row['postCont'];
$imagem = $row['imagem'];
?>
<div class="col-lg-12 text-center">
<img class="img-responsive img-border img-full" <?php echo $imagem; ?> alt="">
<h2><?php echo $titulo; ?><br>
<small><?php echo $subtitulo; ?></small></h2>
<p><?php echo $conteudo; ?></p>
<a href="#" class="btn btn-default btn-lg">Ler</a>
<hr>
</div>
</div>
<?php
}

 

?>
o codigo fonte da pagina no browser :
<div class="col-lg-12 text-center"> <img class="img-responsive img-border img-full" src=img/slide.png alt=""> <h2>How Hermes Requisitioned His Groove Back<br> <small>Now Fry, it's been a head.</small></h2> <p>The Luck of the Fryrish Professor, make a woman out of me. I am the man with no name, Zapp Brannigan! Good man. case while awaiting trial for that there incompetence. It must be wonderful. Where No Fan Has Gone Before Who are those horrible orange men? Bender, we're trying our best. Please, Don-Bot… look into your hard drive, and open your mercy file! Wow! A superpowers drug you can just rub onto your skin? You'd think it would be something you'd have to freebase. WINDMILLS DO NOT WORK THAT WAY! GOOD NIGHT! Look, last night was a mistake. I'm sorry, guys. I never meant to hurt you. Just to destroy everything you ever believed in. Stop it, stop it. It's fine. I will 'destroy' you! You guys realize you live in a sewer, right? Fear of a Bot Planet Why yes! Thanks for noticing. Hey, guess what you're accessories to. Yes, except the Dave Matthews Band doesn't rock. Take me to your leader! Daddy Bender, we're hungry.</p> <a href="#" class="btn btn-default btn-lg">Ler</a> <hr> </div> </div> <div class="col-lg-12 text-center"> <img class="img-responsive img-border img-full" src=img/slide-2.png alt=""> <h2>That Darn Katz!<br> <small>How can any of us trust you?</small></h2> <p>It must be wonderful. Does anybody else feel jealous and aroused and worried? Is today's hectic lifestyle if you want children beaten, you have to do it yourself. </p> <a href="#" class="btn btn-default btn-lg">Ler</a> <hr> </div> </div> <div class="col-lg-12 text-center"> <img class="img-responsive img-border img-full" src="img/slide-1.png" alt=""> <h2>Bendless Love<br> <small>the all like a house of cards.</small></h2> <p>The Mutants Are Revolting We don't have a brig. And until then, I can never die? We need rest. The spirit is willing, but the flesh is spongy and bruised. And yet you haven't said what I told you to say! How can any of us trust you?</p> <a href="#" class="btn btn-default btn-lg">Ler</a> <hr> </div> </div>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.