Foros del Web » Creando para Internet » Diseño web »

Cambio automatico de imagen segun la hora y el dia

Estas en el tema de Cambio automatico de imagen segun la hora y el dia en el foro de Diseño web en Foros del Web. que tal gente.. bueno.. les comento primero que nada que soy principiante pero poco a poco he dieñado mi pagina... Tengo una radio online y ...
  #1 (permalink)  
Antiguo 02/08/2008, 15:38
 
Fecha de Ingreso: diciembre-2007
Mensajes: 3
Antigüedad: 16 años, 3 meses
Puntos: 0
Cambio automatico de imagen segun la hora y el dia

que tal gente.. bueno.. les comento primero que nada que soy principiante pero poco a poco he dieñado mi pagina...
Tengo una radio online y quiero poner una imagen automaticamente en mi web correspondiente al programa de radio que se esta emitiendo en ese momento.
O sea que necesito autocargar una imagen diferente a cada hora (a veces cada media) y varia tambien segun el dia de la semana.
Probe con un cadigo php que encontre en este foro pero no anduvo.. seguramente me falto poner algo..
aqui les mando el cod que parecia mas adecuado para lo que necesito...para que lo descarten o me digan que mas necesita tener..
Aclaro que estara en una pagina independiente del resto.. osea que lo insertare con un iframe... o diganme como insertarlo en la pagina principal...
Disculpen la joda

<!-- Codigo de la imagen cambiante -->
<?php
$h = date('G'); //set variable $h to the hour of the day
$d = date('w'); //set variable $d to the day of the week.
$year = date('Y'); //set variable $year to the current year
//G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
// Adjust 2 hour offset for MST below.
$h = $h+2;

// MONDAY SCHEDULE
if ($d == 1 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
else if ($d == 1 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
else if ($d == 1 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
else if ($d == 1 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
else if ($d == 1 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
else if ($d == 1 && $h >= 15 && $h < 19) $img = 'img/hosts/lizzy.jpg';
else if ($d == 1 && $h >= 19) $img = 'img/hosts/danic.jpg';
else if ($d == 2 && $h < 0) $img = 'img/hosts/danic.jpg';

// TUESDAY SCHEDULE
if ($d == 2 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
else if ($d == 2 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
else if ($d == 2 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
else if ($d == 2 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
else if ($d == 2 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
else if ($d == 2 && $h >= 15 && $h < 17) $img = 'img/hosts/lizzy.jpg';
else if ($d == 2 && $h >= 17 && $h < 20) $img = 'img/hosts/westmar.jpg';
else if ($d == 2 && $h >= 20) $img = 'img/hosts/danic.jpg';
else if ($d == 3 && $h < 0) $img = 'img/hosts/danic.jpg';

// WEDNESDAY SCHEDULE
if ($d == 3 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
else if ($d == 3 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
else if ($d == 3 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
else if ($d == 3 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
else if ($d == 3 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
else if ($d == 3 && $h >= 15 && $h < 19) $img = 'img/hosts/lizzy.jpg';
else if ($d == 3 && $h >= 19) $img = 'img/hosts/danic.jpg';
else if ($d == 4 && $h < 0) $img = 'img/hosts/danic.jpg';

// THURSDAY SCHEDULE
if ($d == 4 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
else if ($d == 4 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
else if ($d == 4 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
else if ($d == 4 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
else if ($d == 4 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
else if ($d == 4 && $h >= 15 && $h < 19) $img = 'img/hosts/lizzy.jpg';
else if ($d == 4 && $h >= 19) $img = 'img/hosts/danic.jpg';
else if ($d == 5 && $h < 0) $img = 'img/hosts/danic.jpg';

// FRIDAY SCHEDULE
if ($d == 5 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
else if ($d == 5 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
else if ($d == 5 && $h >= 8 && $h < 10) $img = 'img/hosts/shonw.jpg';
else if ($d == 5 && $h >= 10 && $h < 12) $img = 'img/hosts/patm.jpg';
else if ($d == 5 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
else if ($d == 5 && $h >= 13 && $h < 15) $img = 'img/hosts/edp.jpg';
else if ($d == 5 && $h >= 15 && $h < 18) $img = 'img/hosts/lizzy.jpg';
else if ($d == 5 && $h >= 18 && $h < 20) $img = 'img/hosts/jeremyb.jpg';
else if ($d == 5 && $h >= 20 && $h < 22) $img = 'img/hosts/exfyl.jpg';
else if ($d == 5 && $h >= 22) $img = 'img/hosts/stickyb.jpg';
else if ($d == 6 && $h < 0) $img = 'img/hosts/stickyb.jpg';

// SATURDAY SCHEDULE
else if ($d == 6 && $h >= 0 && $h < 4) $img = 'arrows.gif';
else if ($d == 6 && $h >= 4 && $h < 5) $img = 'arrows.gif';
else if ($d == 6 && $h >= 5 && $h < 8) $img = 'arrows.gif';
else if ($d == 6 && $h >= 8 && $h < 9) $img = 'arrows.gif';
else if ($d == 6 && $h >= 9 && $h < 10) $img = 'arrows.gif';
else if ($d == 6 && $h >= 10 && $h < 11) $img = 'arrows.gif';
else if ($d == 6 && $h >= 11 && $h < 12) $img = 'arrows.gif';
else if ($d == 6 && $h >= 12 && $h < 13) $img = 'arrows.gif';
else if ($d == 6 && $h >= 13 && $h < 14) $img = 'arrows.gif';
else if ($d == 6 && $h >= 14 && $h < 15) $img = 'arrows.gif';
else if ($d == 6 && $h >= 15 && $h < 17) $img = 'arrows.gif';
else if ($d == 6 && $h >= 17 && $h < 19) $img = 'arrows.gif';
else if ($d == 6 && $h >= 19 && $h < 22) $img = 'arrows.gif';
else if ($d == 6 && $h >= 22) $img = 'arrows.gif';
else if ($d == 0 && $h < 0) $img = 'arrows.gif';

// SUNDAY SCHEDULE
else if ($d == 0 && $h >= 0 && $h < 2) $img = 'img/hosts/darrelm.jpg';
else if ($d == 0 && $h >= 2 && $h < 4) $img = 'img/hosts/techtronic.jpg';
else if ($d == 0 && $h >= 4 && $h < 5) $img = 'img/hosts/bigjon.jpg';
else if ($d == 0 && $h >= 5 && $h < 6) $img = 'img/hosts/joebear.jpg';
else if ($d == 0 && $h >= 6 && $h < 8) $img = 'img/hosts/russh.jpg';
else if ($d == 0 && $h >= 8 && $h < 9) $img = 'img/hosts/ronk.jpg';
else if ($d == 0 && $h >= 9 && $h < 10) $img = 'img/hosts/rockpoint.jpg';
else if ($d == 0 && $h >= 10 && $h < 11) $img = 'img/hosts/churchatqc.jpg';
else if ($d == 0 && $h >= 11 && $h < 12) $img = 'img/hosts/desertcf.jpg';
else if ($d == 0 && $h >= 12 && $h < 16) $img = 'img/hosts/kristenm.jpg';
else if ($d == 0 && $h >= 16 && $h < 17) $img = 'img/hosts/cdogg.jpg';
else if ($d == 0 && $h >= 17 && $h < 18) $img = 'img/hosts/snarf_daff.jpg';
else if ($d == 0 && $h >= 18 && $h < 19) $img = 'img/hosts/sonicsociety.jpg';
else if ($d == 0 && $h >= 19 && $h < 21) $img = 'img/hosts/jscott.jpg';
else if ($d == 0 && $h >= 21) $img = 'img/hosts/ghostlytalk.jpg';
else if ($d == 1 && $h < 0) $img = 'img/hosts/ghostlytalk.jpg';
?>

<!-- Codigo de la imagen cambiante -->
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:05.