← Desenvolvimento

Script em PHP para uma galeria de imagens rotativa

Lida 19254 vezes

Offline

morpheus 
Membro
Mensagens 1199 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

claro que é... mas a ideia era ser, para já, uma coisa simples.

depois, podemos fazer 2 coisas... um false random e um true random.

o false escolhe apenas 1 ao calhas e faz uma sequencia a partir desse, ou seja, temos 2 3 4 ou 4 5 6 ou 1 2 3, mas nunca 1 3 5.

o true random, bem, o nome diz tudo... 1 3 7, 2 9 6, 1 7 4, mas nunca 1 1 2 ou 9 1 9...

para uma lição seguinte!  :wink:
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

:D  Tens razão! Ainda tenho essas vagas noções de PHP ;)
Offline

morpheus 
Membro
Mensagens 1199 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

Citação de: "cremosin"
Citação de: "fpware"
Deve ser possível impedir que uma fotografia se repita na página, certo?


Exato. Ai vai valer muito dinheiro  :P

No caso da probabilidade:

Quero exibir dois de três objetos de cada vez:

1/3 e 1/2 = 1/6 ou 16,67% de propabilidade dos objetos não se repetirem.


se são só dois em três, usa assim:

Citar
<?
$max=3;
$repeat=2;
$control='';

function make_seed(){
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);}

$i=0;
while($i<$repeat){
$i++;
srand(make_seed());
$random = (rand(1, $max));
if($random==$control){
   while($random==$control){
      $random = (rand(1, $max));}}
$control=$random;


if($random=='1'){echo"<a href='LINK1'><img border='0' src='imagens/1.jpg' width='100' height='150'></a>&nbsp;";}
if($random=='2'){echo"<a href='LINK2'><img border='0' src='imagens/2.jpg' width='100' height='150'></a>&nbsp;";}
if($random=='3'){echo"<a href='LINK3'><img border='0' src='imagens/3.jpg' width='100' height='150'></a>&nbsp;";}
}
?>


não se repetem... nunca...
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Ena! Este tipo cada vez mais me surpreende!  :D  :D  :D
Offline

Tartaruga 
Membro
Mensagens 2908 Gostos 1
Troféus totais: 29
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2

eu concordo ctg fpware... em TUDO o que disseste acima!
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

:lol:  :lol:  :lol:

Pois...
Offline

MiguelTavares 
Membro
Mensagens 3871 Gostos 0
Troféus totais: 33
Trófeus: (Ver todos)
Avatar Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5 Level 4

Excelente! :D
Offline

surfrib 
Membro
Mensagens 213 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Este script funciona mesmo???
Offline

morpheus 
Membro
Mensagens 1199 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

comigo funciona!  8)
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Funciona na perfeição! :D
Offline

surfrib 
Membro
Mensagens 213 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

ok!!!

VOu ver se consigo por a bombar!!

Se gravarmos o script com a extensão html ele funciona na mesma??
Offline

morpheus 
Membro
Mensagens 1199 Gostos 0
Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 1000 Posts

Citação de: "surfrib"
ok!!!

VOu ver se consigo por a bombar!!

Se gravarmos o script com a extensão html ele funciona na mesma??


nop! php só funciona com extensão php!

e num servidor com suporte php. cuidado!
Offline

surfrib 
Membro
Mensagens 213 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

oohhhhhhhhhh...


OK, vou ja tratar disso!
Offline

surfrib 
Membro
Mensagens 213 Gostos 0
Troféus totais: 29
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Alguem tem isso a funcionar nalguma pagina??
Offline

fpware 
Fundador
Mensagens 15318 Gostos 7
Troféus totais: 38
Trófeus: (Ver todos)
Linux User Mobile User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter Level 5

Não, mas se quiseres mesmo posso colocar uma online.

Estás a ter problemas com o código?