Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Jak połączyć
stern
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 3.08.2009

Ostrzeżenie: (0%)
-----


Witam, chciałem w swojej galerii zrobić losowe wyświetlanie zdjęć. Nie wiem w którym miejscu wkleić php do html żeby działało :/


to są kody:
  1. <title>Galery</title>
  2. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-5" />
  3. <link rel="stylesheet" type="text/css" href="style2.css" />
  4. </head>
  5.  
  6. <table width="100%" cellpadding="0" cellspacing="0" style="height:100%">
  7. <tr>
  8. <td class="left"><img src="images/spacer.gif" width="1" height="1" alt="" /></td>
  9. <td class="middle">
  10. <p style="cursor:crosshair;"><img src="images/logo.gif" alt="" width="700" height="180" class="float" /></p>
  11. <div class="leftcol">
  12. </div>
  13. <div class="rightcol">
  14. <div class="group">
  15. <a target="_blank" href="art/CCI_00000.jpg"><img src="art/CCI_00000.jpg" alt="Girl" width="57" height="78" /></a>
  16. <a target="_blank" href="art/CCI_00001.jpg"><img src="art/CCI_00001.jpg" alt="Girl" width="57" height="78" /></a>
  17. <a target="_blank" href="art/CCI_00002.jpg"><img src="art/CCI_00002.jpg" alt="Girl" width="57" height="78" /></a>
  18. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  19. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  20. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  21. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  22. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  23. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  24. <a target="_blank" href="#"><img src="" alt="" width="57" height="57" /></a>
  25. </div>
  26. </div>
  27. </td>
  28. <td class="right"><img src="images/spacer.gif" width="1" height="1" alt="" /></td>
  29. </tr>
  30. </table>
  31. </body>
  32. </html>


  1. <?php
  2. $dir = './images/';
  3. $exts = array( 'gif', 'jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'GIF', 'PNG' );
  4. $imgs = array();
  5. if( $d = opendir( $dir ) )
  6. {
  7. while( $f = readdir( $d ) )
  8. {
  9. $ext = explode( '.', $f );
  10. $ext = array_pop( $ext );
  11. if( in_array( strtolower( $ext ), $exts ) )
  12. {
  13. $imgs[] = $f;
  14. }
  15. }
  16. closedir( $d );
  17. }
  18.  
  19. $img = $imgs[ array_rand( $imgs ) ];
  20. echo '<img src="' . $dir . $img . '"/>';
  21.  
  22.  
  23. ?>


Chodzi mi o to aby losowe zdjęcie pokazywało się po lewej stronie galerii.
Tu jest stronka testowa http://mist-sn.ugu.pl/galery.html

Ten post edytował stern 28.12.2009, 11:47:52
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 30.09.2025 - 08:21