Miguel85 Posted March 13, 2014 Report Share Posted March 13, 2014 (edited) 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 March 14, 2014 by yoda Link to comment Share on other sites More sharing options...
Miguel85 Posted March 13, 2014 Author Report Share Posted March 13, 2014 (edited) RESOLVIDO: PHP: <div id ="newsText"> <?php for ($id=0; $id < count($articles); $id++) { echo ("<p id=".$id.">".$articles[$id]['article_content']."</p>"); } ?> </div> Edited March 14, 2014 by yoda Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now