Ver Mensaje Individual
  #10 (permalink)  
Antiguo 26/01/2010, 06:14
turminator
 
Fecha de Ingreso: enero-2006
Ubicación: Barcelona, España
Mensajes: 126
Antigüedad: 18 años, 3 meses
Puntos: 1
Respuesta: Alternar enlaces con PHP

Hola Ryo,

Entoces podría dejarlo así el código?

Código PHP:
<?php

//Lista de enlaces
$enlace[1]="<object width=\"340\" height=\"285\"><param name=\"movie\" value=\"http://www.youtube.com/v/60KBUdgRCRw&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/60KBUdgRCRw&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"340\" height=\"285\"></embed></object>";
$enlace[2]="<object width=\"340\" height=\"285\"><param name=\"movie\" value=\"http://www.youtube.com/v/gGDS_Q15xsg&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/gGDS_Q15xsg&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"340\" height=\"285\"></embed></object>";
$enlace[3]="<object width=\"340\" height=\"285\"><param name=\"movie\" value=\"http://www.youtube.com/v/gGDS_Q15xsg&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/gGDS_Q15xsg&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"340\" height=\"285\"></embed></object>";
$enlace[4]="<object width=\"340\" height=\"285\"><param name=\"movie\" value=\"http://www.youtube.com/v/ELvU4inKfQI&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/ELvU4inKfQI&hl=es_ES&fs=1&color1=0xe1600f&color2=0xfebd01&border=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"340\" height=\"285\"></embed></object>";

//Calculo el numero total de enlaces
$total_enlaces count($enlace);

//Genero numero aleatorio sin superar a enlaces
$aleatorio=rand(1,$total_enlaces);

//Escribo el vinculo
echo "<div align='center'>$enlace[$aleatorio]</div>";

?>
Lo acabo de probar y no funciona, parece que esté todo bien, no?