Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/10/2010, 07:23
Avatar de Nano_
Nano_
 
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 2 meses
Puntos: 96
Respuesta: rotacion de noticia

Saludos


No se si sea de esta forma que lo necesitas.

Utilizando la funcion rand de mysql y un if dentro del while


Código PHP:
<?php
$rs
=mysql_query("SELECT * FROM noticias ORDER BY RAND() DESC limit 5");
        if (
mysql_num_rows($rs)){
//Iniciliazo variable
$i=1;
        while(
$c2 mysql_fetch_row($rs)){

if(
$i<4){
    
?>
    <table width="362" height="63" cellspacing="0" cellpadding="2">
                <tr>
                    <td width="214" height="25" class="titulo"><? echo $c2[4]; ?></td>
                    <td width="148" class="formulario">&nbsp;</td>
                </tr>
                <tr>
                   <td height="36" colspan="2" valign="top" class="parrafo"><? echo $c2[2]; ?>
                  </td>
                 </tr>
                </table>
                <?
}
$i++;
                }
                }else{
                die(
'No hay noticias');
                }
__________________
:.:Nano.:: @nano_hard - Retornando al foro

Última edición por Nano_; 28/10/2010 a las 07:29