Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   PHP (https://www.clubdelphi.com/foros/forumdisplay.php?f=15)
-   -   Noticias con tiempo limitado (https://www.clubdelphi.com/foros/showthread.php?t=68018)

CniL 19-05-2010 22:59:41

Noticias con tiempo limitado
 
2 archivo
shownoti.php y noticias.php

una vez ya conectado a tu BD
imagina una tabla en la BD con
ID/FECHA/NOTICIA/LINK
------------------------
1 / 2010-05-18 / Acá la noticia / Link relacionado con la noticia
2 / otra fecha / otra noticia / otro link
ETC...

shownoti.php
Código PHP:

        <?php //CONSULTA SI HAN PASADO 3 DIAS DE ULTIMA NOTICIA
              
$consulta=mysql_query("SELECT fecha FROM noticias ORDER BY id DESC LIMIT 1");
            
$datos=mysql_fetch_array($consulta);
            
$fnoti=$datos['fecha'];
            
$fhoy=date ("Y-m-d");
            
$dias=diferenciafechas($fhoy,$fnoti);
            if(
$dias<3)
            {
        
?>
        <div id="noticias">
        <?php include("noticias.php");?>
        </div><!-- FIN NOTICIAS -->
        <?php
            
}
        
?>

noticias.php
Código PHP:

<?php
  $seleccion
="SELECT fecha,autor,titulo,noticia,link FROM noticias ORDER BY id DESC LIMIT 1" ;
  
$consulta=mysql_query($seleccion,$conn);
  
$datos=mysql_fetch_array($consulta,$seleccion_db);
  
?>
<h3><strong>Noticia:</strong></h3>
<h4><strong>Título</strong>: "<?php if($datos['link']){?><a href='<?php echo $datos['link']?>'><?php echo $datos['titulo'];?>"</a><?php }else{ echo $datos['titulo'];?>"<?php ?></h4><hr>
<h5><?php echo $datos['noticia'];?></h5><hr>
<h6><strong>Escrito por</strong> <i><?php echo $datos['autor'];?></i> /<strong> El Día</strong> <i><?php echo $datos['fecha'];?></i></h6>


CniL 19-05-2010 23:00:39

Donde está el dias<3 es donde pones la cantidad de días que dure la noticia ONLINE

es para BD MYSQL

movorack 19-05-2010 23:29:21

????????

tutorial? truco? duda? problema?

CniL 20-05-2010 22:57:23

Cita:

Empezado por movorack (Mensaje 364694)
????????

tutorial? truco? duda? problema?

Compartiendo


La franja horaria es GMT +2. Ahora son las 10:16:23.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi