Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/09/2008, 19:49
Avatar de vidalsoft
vidalsoft
 
Fecha de Ingreso: julio-2008
Ubicación: /www/...
Mensajes: 339
Antigüedad: 15 años, 9 meses
Puntos: 1
Respuesta: Cambiar imagen en un div

HOla prueba asi:
Código PHP:

<?php
$idurl 
$_GET['id'];// Obtienes la id de la categoria seleccionada la cual enviaste por url

if (!empty($id)){// si existe un valor en la variable idurl hace lo siguiente

//las constantes de este case las cambias segun los id's de tus categorias
switch($idurl){
case 
1:
echo 
"<div id = \"divXCambiar\" style='float: none; width: auto; height: 150px; background: url(./images/banner-deporte.gif) no-repeat; clear: both;'></div>";
break;

case 
2:
echo 
"<div id = \"divXCambiar\" style=\"float: none; width: auto; height: 150px; background: url(./images/culturales1.gif) no-repeat; clear: both;\"></div>";
break;

case 
3:
echo 
"<div id = 'divXCambiar' style='float: none; width: auto; height: 150px; background: url(./images/banners_economia.jpg) no-repeat; clear: both;'></div>";
break;

case 
10:
echo 
"<div id = 'divXCambiar' style='float: none; width: auto; height: 150px; background: url(./images/internacionales.jpg) no-repeat; clear: both;'></div>";
break;

default: 
// esta opcion se activa si pasa un numero que no este en el rango de las categorias
echo "<div id = \"divXCambiar\" style=\"float: none; width: auto; height: 150px; background: url(./images/new_image0.gif) no-repeat; clear: both;\"></div>";
break;
}
}else{ 
// si NO existe un valor en la variable idurl hace lo siguiente
echo "<div id = \"divXCambiar\" style=\"float: none; width: auto; height: 150px; background: url(./images/new_image.gif) no-repeat; clear: both;\"></div>";
}
?>
Tu problema es que en el prIMer case gualas la variable de condicion $idurl=1 por eso imprime siempre la primera.
Saludos...
__________________
Anthony Vidal Contreras | @AnthonyVidalC | Skype: vidalsystem | [email protected]