Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL][PHP][JavaScript]Źle wyswietla się rotacja zdjęć
Forum PHP.pl > Forum > Przedszkole
szczalpi
Witam
Mam problem z rotacją zdjęć. Źle mi się wyświetlają. Do rotacji używam jquery. Link do pliku Link
Kod w php
  1. mysql_query("SET NAMES 'latin2'");
  2. $result = mysql_query("SELECT count(*) FROM users where id");
  3. $do = mysql_fetch_row($result);
  4. $random = mt_rand(0,$do[0] - 1);
  5. $result = mysql_query("SELECT * FROM users LIMIT $random, 10");
  6.  
  7. while ($rowek = mysql_fetch_array($result)) {
  8.  
  9. ?>
  10.  
  11.  
  12. <a href="http://www.ewypoczywaj.pl/<? echo $rowek['id']; ?>.html" class="show">
  13. <img src="http://www.ewypoczywaj.pl/users_fotos/<? echo $rowek['photo_1']; ?>" alt="<? echo $rowek['nazwa_obiektu'];?>" width="580" height="360" title="" alt="" rel="<h3><? echo $rowek['nazwa_obiektu'];?></h3><? echo substr($rowek['opis'],0,200);?> "/>
  14. </a>
  15.  
  16.  
  17.  
  18. <?
  19.  
  20.  
  21. }

Nie wiem czy źle mam coś zrobione w rotacji funkcji.
Poniżej przedstawię cały kod jaki mam w pliku
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Language" content="pl" />
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  7. <script type="text/javascript">
  8.  
  9. $(document).ready(function() {
  10.  
  11. //Execute the slideShow
  12. slideShow();
  13.  
  14. });
  15.  
  16. function slideShow() {
  17.  
  18. //Set the opacity of all images to 0
  19. $('#gallery a').css({opacity: 0.0});
  20.  
  21. //Get the first image and display it (set it to full opacity)
  22. $('#gallery a:first').css({opacity: 0.8});
  23.  
  24. //Set the caption background to semi-transparent
  25. $('#gallery .caption').css({opacity: 0.5});
  26.  
  27. //Resize the width of the caption according to the image width
  28. $('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
  29.  
  30. //Get the caption of the first image from REL attribute and display it
  31. $('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
  32. .animate({opacity: 0.7}, 400);
  33.  
  34. //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
  35. setInterval('gallery()',6000);
  36.  
  37. }
  38.  
  39. function gallery() {
  40.  
  41. //if no IMGs have the show class, grab the first image
  42. var current = ($('#gallery a.show')? $('#gallery a.show') : $('#gallery a:first'));
  43.  
  44. //Get next image, if it reached the end of the slideshow, rotate it back to the first image
  45. var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));
  46.  
  47. //Get next image caption
  48. var caption = next.find('img').attr('rel');
  49.  
  50. //Set the fade in effect for the next image, show class has higher z-index
  51. next.css({opacity: 0.0})
  52. .addClass('show')
  53. .animate({opacity: 1.0}, 1000);
  54.  
  55. //Hide the current image
  56. current.animate({opacity: 0.0}, 1000)
  57. .removeClass('show');
  58.  
  59. //Set the opacity to 0 and height to 1px
  60. $('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });
  61.  
  62. //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
  63. $('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
  64.  
  65. //Display the content
  66. $('#gallery .content').html(caption);
  67.  
  68.  
  69. }
  70.  
  71. </script>
  72. <style type="text/css">
  73. body{
  74. font-family:arial
  75. }
  76.  
  77. .clear {
  78. clear:both
  79. }
  80.  
  81. #gallery {
  82. position:relative;
  83. height:360px
  84. }
  85. #gallery a {
  86. float:left;
  87. position:absolute;
  88. }
  89.  
  90. #gallery a img {
  91. border:none;
  92. }
  93.  
  94. #gallery a.show {
  95. z-index:500
  96. }
  97.  
  98. #gallery .caption {
  99. z-index:600;
  100. background-color:#000;
  101. color:#ffffff;
  102. height:100px;
  103. width:100%;
  104. position:absolute;
  105. bottom:0;
  106. }
  107.  
  108. #gallery .caption .content {
  109. margin:5px
  110. }
  111.  
  112. #gallery .caption .content h3 {
  113. margin:0;
  114. padding:0;
  115. color:#1DCCEF;
  116. }
  117.  
  118.  
  119. </style>
  120. </head>
  121.  
  122. <body>
  123. <div id="gallery">
  124. <?
  125.  
  126. mysql_query("SET NAMES 'latin2'");
  127. $result = mysql_query("SELECT count(*) FROM users where id");
  128. $do = mysql_fetch_row($result);
  129. $random = mt_rand(0,$do[0] - 1);
  130. $result = mysql_query("SELECT * FROM users LIMIT $random, 10");
  131.  
  132. while ($rowek = mysql_fetch_array($result)) {
  133.  
  134. ?>
  135.  
  136. <a href="http://www.ewypoczywaj.pl/<? echo $rowek['id']; ?>.html" class="show">
  137. <img src="http://www.ewypoczywaj.pl/users_fotos/<? echo $rowek['photo_1']; ?>" alt="<? echo $rowek['nazwa_obiektu'];?>" width="580" height="360" title="" alt="" rel="<h3><? echo $rowek['nazwa_obiektu'];?></h3><? echo substr($rowek['opis'],0,200);?> "/>
  138. </a>
  139. <?
  140.  
  141.  
  142. }
  143.  
  144.  
  145. // koniec if
  146. ;?><div class="caption"><div class="content"></div></div>
  147.  
  148.  
  149. </div>
  150. <div class="clear"></div>
  151.  
  152.  
  153.  
  154. </body>
  155. </html>
Proszę was o pomoc
nospor
Cytat
Źle mi się wyświetlają.
Jak cos ci sie źle wyswietla, to bądź na tyle miły i napisz nam co masz na mysli a nie kazesz nam sie domyslac :/

CHodzi ci o to, ze na poczatku wyswietla ci sie caly czas ten sam obrazek przez pare kolejek? To pewnie spowodowane jest tym, ze wszystkim elementom na dzien dobry nadajesz klase SHOW. A tylko pierwszy powinien mieć te klase

ps:
$random = mt_rand(0,$do[0] - 1);
$result = mysql_query("SELECT * FROM users LIMIT $random, 10");
ale zdajesz sobie sprawe z tego, ze jak ten twoj random wylosuje np. przedostatni rekord, to na stronie wyswietlą ci sie tylko dwa obrazki?
szczalpi
  1. $random = mt_rand(0,$do[0] - 1);
  2. $result = mysql_query("SELECT * FROM users LIMIT $random, 10");

Proszę o na kierowanie co powinien zmienić, aby prawidłowo się wyświetlało lub co zmienić.
Dziękuje
nospor
Napisalem ci co masz zrobic. Tylko pierwszy element ma miec klase SHOW a nie wszystkie
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.