Tutoriales
Tutoriales ~ php ~ Imagenes al Azar| Imagenes al Azar | |
|
Fecha: 2008-12-07 Nivel: Facil Impresiones: 1 Autor: Shinji Categoria: php Descripcion: Con este tutorial aprenderas a crear un rotador de imagenes al azar.. |
Bookmark:
![]() E-mail to a friend View printable version Permanlink |
En este articulo veremos como agregar un rotador de imágenes al azar con un simple código php
Codigo:
<?php $numbanners = 4;
$random = rand(1,$numbanners);
$img = array();
$url = array();
$txt = array();
$img[1] = "http://www.web.com/imagen1.gif";
$url[1] = "http://www.web.com";
$txt[1] = "alt text";
$img[2] = "http://www.web.com/imagen2.gif";
$url[2] = "http://www.web.com";
$txt[2] = "alt text";
$img[3] = "http://www.web.com/imagen3.gif";
$url[3] = "http://www.web.com";
$txt[3] = "alt text";
$img[4] = "http://www.tuweb.com/imagen4.gif";
$url[4] = "http://www.web.com";
$txt[4] = "alt text";
echo "<a href='$url[$random]' target=' _blank '><img src='$img[$random]' alt='$txt[$random]' border=' 0 '></a>";
?>
Esta línea nos dice el numero de imágenes a rotar esta parte la puedes editar para agregar mas.
$numbanners = 4;
Aquí debes poner la url de la imagen el [1] es el identificador
$img[1] = "http://www.web.com/banner1.gif";
Aquí debes poner el url, el [1] es el identificador
$url[1] = "http://www.web.com";
En esta línea sirve para poner un alt text a la imagen correspondiente al identificador
$txt[1] = "alt text";
Puedes ir agregando mas cambiando el identificador []
Este código lo sitúas en la parte donde quieres que se vea la imagen
echo "<a href='$url[$random]' target=' _blank '><img src='$img[$random]' alt='$txt[$random]' border=' 0 '></a>";
Este es un ejemplo, (puedes dar a actualizar para Checar la función):
Comentarios
No hay Comentarios.
Ads
Ultimos Tutoriales
Efecto de Luz en: photoshop el: 2008-12-08 por: Shinji
Triple Borde en: photoshop el: 2008-12-08 por: Shinji
Fondos con Pinceles en: photoshop el: 2008-12-08 por: Shinji
Glowing Skin en: photoshop el: 2008-12-08 por: Shinji
Negar Acceso a Archivos en: misc el: 2008-12-07 por: Shinji







