Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/02/2007, 16:59
joel_elserver
 
Fecha de Ingreso: noviembre-2003
Mensajes: 78
Antigüedad: 20 años, 5 meses
Puntos: 2
Re: Problema al borrar una id y rotar

snake10,

Seguramente podés lograr el mismo efecto realizando la parte de "azar" directamente con MySQL, sin importar si los id son consecutivos o no, y sin necesidad de "reasignar" el id a todos los banners cuando borrás uno. Estoy asumiendo que en el script original el id es único para cada banner.
El código modificado sería algo así:


Código PHP:
<?php
include("config.php");
$query mysql_query("SELECT * FROM banners ORDER BY RAND() LIMIT 1");
if(
$row mysql_fetch_assoc($query)) {
 echo 
'<table width="88" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><a href="'
.$row['url'].'" target=_blank><img src="'.$row['banner'].'" width="88" height="31" border="0"></a></td>
  </tr>
</table>'
;
 }
?>
Espero te sirva.

Saludos!
__________________
Joel A. Chornik
ELSERVER.COM - WebHosting Profesional