PF2G Posted August 8, 2012 at 03:10 PM Report Share #471748 Posted August 8, 2012 at 03:10 PM Boas Eu estou a tentar fazer um slideshow de imagens em carousel. Mas não me aparecem as imagens todas, alguem me pode ajudar? head <link href="style_carousel.css" rel="stylesheet" type="text/css" /> <!-- jQuery library --> <script type="text/javascript" src="js/lib/jquery-1.4.2.min.js"></script> <!-- jCarousel library --> <script type="text/javascript" src="js/lib/jquery.jcarousel.min.js"></script> <!-- jCarousel skin stylesheet --> <link rel="stylesheet" type="text/css" href="images/skins/ie7/skin.css" /> <script type="text/javascript"> <?php $select_images="SELECT * FROM bj_sub_gal"; $query_images=mysql_query($select_images, $connect) or die(mysql_error()); $images=mysql_fetch_assoc($query_images); do{ ?> var mycarousel_itemList = [ {url: "<?php echo $images['sub_gal_imagem']; ?>", title: "<?php echo $images['sub_gal_nome']; ?>"}, ]; <?php }while($images=mysql_fetch_assoc($query_images)) ?> function mycarousel_itemLoadCallback(carousel, state) { for (var i = carousel.first; i <= carousel.last; i++) { if (carousel.has(i)) { continue; } if (i > mycarousel_itemList.length) { break; } carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[i-1])); } }; /** * Item html creation helper. */ function mycarousel_getItemHTML(item) { return '<a href="<?php echo $images['sub_gal_imagem']; ?>" rel="gallery" class="pirobox_gall">'; return '<img src="' + item.url + '" width="200" height="200" alt="' + item.url + '" /></a>'; }; jQuery(document).ready(function() { jQuery('#mycarousel').jcarousel({ size: mycarousel_itemList.length, itemLoadCallback: {onBeforeAnimation: mycarousel_itemLoadCallback} }); }); </script> div imagens: <!----------------IMAGES---------------------> <ul id="mycarousel" class="jcarousel-skin-ie7"> <!-- The content will be dynamically loaded in here --> </ul> <!----------------end/IMAGES-----------------> Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 8, 2012 at 09:15 PM Report Share #471776 Posted August 8, 2012 at 09:15 PM tenta descobrir o resultado deste código: do{ ?> var mycarousel_itemList = [ {url: "<?php echo $images['sub_gal_imagem']; ?>", title: "<?php echo $images['sub_gal_nome']; ?>"}, ]; <?php }while($images=mysql_fetch_assoc($query_images)) - acho que foi a ti que disse para ter muito cuidado com o uso da estrutura de controlo do {} while achoq ue te disse para usar sempre o while {} e só optar pelo do {} while em último caso ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
PF2G Posted August 9, 2012 at 09:07 AM Author Report Share #471794 Posted August 9, 2012 at 09:07 AM Ja experimentei fazer o while{} e não aparece nada enquanto com o do{}while() aparece uma imagem só - quando tenho duas na BD. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 9, 2012 at 09:13 AM Report Share #471796 Posted August 9, 2012 at 09:13 AM então estás a dizer que se não consegues apertar um parafuso com uma chave de fendas usas um martelo, porque dessa maneira, pelo menos, sempre entra metade na madeira ??? em programação não existe essa mentalidade, porque simplesmente não funciona e o resultado do erro é imediato (ao contrário do exemplo anterior) no entanto a minha pergunta foi : tenta descobrir o resultado deste código: e tu não apresentas nenhuma conclusão sobre essa pergunta ... 1 Report IRC : sim, é algo que ainda existe >> #p@p Portugol Plus 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