Jump to content

[Resolvido] PHP MySQL, Slider


Miguel85
 Share

Recommended Posts

Estou a trabalhar num slider de artigos, cujo estes artigos estão numa database podendo ser eleminados/adicionados (CMS), está tudo a trabalhar na perfeição, a database, e o slider se existirem tags 'p' estáticas funciona muito bem. Agora só queria integrar os artigos no slider. Aqui está o meu código, o que está a acontecer é que os artigos estão a aparecer(fadeIn) todos ao mesmo tempo uns em cima dos outros e não faz loop, é um erro de lógica com certeza. Alguma dica? Obrigado

JS:

sliderInt=1;
sliderNext=2;
$("#newsText > p#1").fadeIn(500);
 startSlider();

function startSlider() {
 count = $("#newsText > p").size();
 loop = setInterval (function() {

 if (sliderNext>count) {

	 sliderNext = 1;
	 sliderInt = 1;
	 }

 $("#newsText > p").fadeOut(500);
 $("#newsText > p#" + sliderNext).delay(500).fadeIn(500);
 sliderInt = sliderNext;
 sliderNext ++;

 } ,7500);
}

function stopLoop() {
 window.clearInterval(loop);
}

function showSlide(id) {
stopLoop();
 if (id>count) {

	 id = 1;
	 }
 else if (id<1) {

	 id=count;
	 }

 $("#newsText > p").fadeOut(500);
 $("#newsText > p#" + id).fadeIn(500);

 sliderInt = id;
 sliderNext = id + 1;
 startSlider();

}

PHP:

<?php
include_once('php/CMS/includes/connection.php');
include_once('php/CMS/includes/article.php');
$article = new Article;
$articles = $article->fetch_all();
?>

......HTML.........

<?php
foreach ($articles as $article){
 for($articles=0; $articles <= count($articles); $articles++) {
 $id = 1;
 echo ("<p id=".$id++.">".$article['article_content']."</p>");
 }
}
?>
Edited by yoda
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.