Foros del Web » Programando para Internet » PHP »

Fecha Desde y Fecha Hasta...

Estas en el tema de Fecha Desde y Fecha Hasta... en el foro de PHP en Foros del Web. Hola, Ahora necesito hacer un listado de noticias, en el que ontroduzco la fecha desde y fechahasta a listar y uqe me liste las noticias ...
  #1 (permalink)  
Antiguo 24/03/2006, 12:36
 
Fecha de Ingreso: marzo-2006
Mensajes: 86
Antigüedad: 18 años, 1 mes
Puntos: 0
Fecha Desde y Fecha Hasta...

Hola, Ahora necesito hacer un listado de noticias, en el que ontroduzco la fecha desde y fechahasta a listar y uqe me liste las noticias en ese rango.
Probé ingresando los datos en listas desplegables, no funcionó...otra vez, con dos cuadros de texto, el tema es que no se como pasar las variable para que las tome el otro archivo que hace el listado..
No poste o el código porque es un desastre..................
Para variar...gracias....
__________________
:stress: Patri:corazon:
  #2 (permalink)  
Antiguo 24/03/2006, 12:57
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Debes indicar como trabajas esos datos, no dices si usas Base de datos .. ni como gestionas ese dato (información) de "fecha" por la cual vas a tener que ejecutar una consulta SQL u otro tipo de programación para ver ese rango de registros que cumplan esa condición.

Especifica que BBDD usas (Mysql? .. cual) y lo dicho; el tipo y formato de fechas que almacenas.

Todo va a depender de eso .. Si tu quieres preguntar la fecha a tu usuario por un "cuadro" de texto .. así (según el formato de esas fechas) lo tendrá que ingresar o tu con PHP tendrás que cambiar su formato para el que en tu BBDD tengas, lo mismo con las "listas" desplegables; tu recojes los datos como vengan y tienes que componer tu "fecha" con el formato que tu BBDD maneje. (Esto se hace "concatenando" como string que son tus variables en el fondo).


Un saludo,
__________________
Por motivos personales ya no puedo estar con Uds. Fue grato haber compartido todos estos años. Igualmente los seguiré leyendo.
  #3 (permalink)  
Antiguo 24/03/2006, 19:40
 
Fecha de Ingreso: marzo-2006
Mensajes: 86
Antigüedad: 18 años, 1 mes
Puntos: 0
perdon....trabajo con mysql, tengo una gase donde ingrese noticias y la fecha con getdate()...
y ahora?
__________________
:stress: Patri:corazon:
  #4 (permalink)  
Antiguo 24/03/2006, 20:54
Avatar de atak  
Fecha de Ingreso: julio-2005
Ubicación: Huancayo
Mensajes: 490
Antigüedad: 18 años, 9 meses
Puntos: 5
De acuerdo Parametros de fecha ....

Hola patriciadedo

Podrias hacer uso de la funcion BETWEEN

Código PHP:
<?php
$fecha_inicio
=$_POST['fecha_inicio'];
$fecha_fin=$_POST['fecha_fin'];
// configuraciones
$sql=mysql_query("SELECT * FROM noticias WHERE fecha BETWEEN '$fecha_inicio'  AND '$fecha_fin'");

WHILE(
$campo=mysql_fetch_array($sql))
{
   echo 
"//////  todo lo que tienes en tu  tabla  ";
}
?>


Espero que te ayude

Salu2

__________________
. .: El mejor Inicio :. .
  #5 (permalink)  
Antiguo 04/04/2006, 20:03
 
Fecha de Ingreso: marzo-2006
Mensajes: 86
Antigüedad: 18 años, 1 mes
Puntos: 0
Acá les paso consulta_noticias, que es donde pido la fecha_inicio y la fecha_fin, y después se va a Litsado_noticias_x_fecha, pero el tema es que no se como hago para que me pase los valores de inicio y fin SOCORROOOOO!!!!!!
Gracias desde ya por la onda que tienen todos...
Aca va consulta----

Cita:
<?php include("../conex.php"); ?>
<html>
<head>
<title>CONSULTA DE NOTICIAS POR FECHA</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body leftmargin="0" topmargin="0">
<table width="100%" height="100%" border="0" cellpadding="8" cellspacing="0">
<tr bgcolor="#99CCCC">
<td height="50" colspan="2"><div align="center"><strong><font size="5"><em>CADENA
SER ARGENTINA</em></font></strong></div></td>
</tr>
<tr>
<td width="21%" valign="top" bgcolor="#99CCCC"> <table width="85%" height="157" border="1" align="left">
<tr>
<td bgcolor="#66CC99"><font size="3"><strong><em>NOTICIAS</em></strong></font></td>
</tr>
<tr>
<td bgcolor="#99CCCC"> <div align="center"><a href="alta_noticias.php">Agregar</a></div></td>
</tr>
<tr>
<td bgcolor="#99CCCC"> <div align="center"><a href="consulta_noticias.php">Consultar</a></div></td>
</tr>
<tr>
<td bgcolor="#66CC99"><font size="3"><strong><em>SECCIONES</em></strong></font></td>
</tr>
<tr>
<td bgcolor="#99CCCC"> <div align="center"><a href="alta_secciones.php">Agregar</a></div></td>
</tr>
<tr>
<td bgcolor="#99CCCC"> <div align="center"><a href="lista_secciones.php">Consultar</a></div></td>
</tr>
<tr>
<td bgcolor="#66CC99"><font size="3"><strong><em>AUTORES</em></strong></font></td>
</tr>
<tr>
<td bgcolor="#99CCCC"> <div align="center"><a href="alta_autor.php">Agregar</a></div></td>
</tr>
<tr>
<td bgcolor="#99CCCC"> <div align="center"><a href="lista_autor.php">Consultar</a></div></td>
</tr>
</table></td>
<td width="82%" valign="top"><p align="center"><strong><font size="4"><em>CONSULTA
DE NOTICIAS POR FECHA.</em></font></strong>
</p>
<p align="center"><a href="consulta_noticias.php">Volver</a> </p>
<form name="form1" method="post" action="">
<table width="70%" border="0" align="center">
<tr>
<td width="26%">Fecha desde:</td>
<td width="74%"><input type="text" name="fecha_inicio"></td>
</tr>
<tr>
<td>Fecha hasta:</td>
<td><input type="text" name="fecha_fin"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<?php
$fecha_inicio=$_POST['fecha_inicio'];
$fecha_fin=$_POST['fecha_fin'];
echo "<a href=lista_noticias_x_fecha.php?fecha_inicio=".$fe cha_inicio."&"."fecha_fin=".$fecha_fin."><b>LISTAD O</b></a>";
?>
</td>
</tr>
</table>
</form>

<p align="center">&nbsp;</p>
<br>
<p align="center">&nbsp;</p>

</p>
</td>
</tr>
</table>
<b></b>
</body>
</html>

este es listado-.....

Cita:
$fecha_inicio=$_POST['fecha_inicio'];
$fecha_fin=$_POST['fecha_fin'];
echo $fecha_inicio;
echo $fecha_fin;
__________________
:stress: Patri:corazon:
  #6 (permalink)  
Antiguo 05/04/2006, 17:55
 
Fecha de Ingreso: marzo-2006
Mensajes: 86
Antigüedad: 18 años, 1 mes
Puntos: 0
hice lio cuando puse el código, aca listado

Código:
<?php include("../conex.php"); 

$registros = 8;

if (!$pagina) { 
    $inicio = 0; 
    $pagina = 1; 
} 
else { 
    $inicio = ($pagina - 1) * $registros; 
} 

?>

<html> 
<head> 
   <title>LISTADO DE NOTICIAS</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> 

<body leftmargin="0" topmargin="0"><table width="100%" height="100%" border="0" cellpadding="8" cellspacing="0">
<table width="100%" height="100%" border="0" cellpadding="8" cellspacing="0">
  <tr bgcolor="#99CCCC"> 
    <td height="50" colspan="2"><div align="center"><strong><font size="5"><em>CADENA 
        SER ARGENTINA</em></font></strong></div></td>
  </tr>
  <tr> 
    <td width="21%" valign="top" bordercolor="#CCCCCC" bgcolor="#99CCCC"> <div align="center"> 
        <table width="85%" height="157" border="1" align="left">
          <tr> 
            <td bgcolor="#66CC99"><font size="3"><strong><em>NOTICIAS</em></strong></font></td>
          </tr>
          <tr> 
            <td bgcolor="#99CCCC"> <div align="center"><a href="alta_noticias.php">Agregar</a></div></td>
          </tr>
          <tr> 
            <td bgcolor="#99CCCC"> <div align="center"><a href="consulta_noticias.php">Consultar</a></div></td>
          </tr>
          <tr> 
            <td bgcolor="#66CC99"><font size="3"><strong><em>SECCIONES</em></strong></font></td>
          </tr>
          <tr> 
            <td bgcolor="#99CCCC"> <div align="center"><a href="alta_secciones.php">Agregar</a></div></td>
          </tr>
          <tr> 
            <td bgcolor="#99CCCC"> <div align="center"><a href="lista_secciones.php">Consultar</a></div></td>
          </tr>
          <tr> 
            <td bgcolor="#66CC99"><font size="3"><strong><em>AUTORES</em></strong></font></td>
          </tr>
          <tr> 
            <td bgcolor="#99CCCC"> <div align="center"><a href="alta_autor.php">Agregar</a></div></td>
          </tr>
          <tr> 
            <td bgcolor="#99CCCC"> <div align="center"><a href="lista_autor.php">Consultar</a></div></td>
          </tr>
        </table>
      </div></td>
    <td width="81%" valign="top"> <p align="center"><strong><font size="4"><em>LISTADO 
        DE NOTICIAS POR FECHA.</em></font></strong> </p>
      <p align="center"><a href="consulta_noticias.php">Volver</a> </p>
      
	  <table border=1 align="center" cellpadding="5" cellspacing="0">
        <tr bgcolor="#99CCCC"> 
          <td width="37" height="40"> <div align="center"><strong>Fecha</strong></div></td>
          <td width="48"> <div align="center"><strong>Secci&oacute;n</strong></div></td>
          <td width="34"> <div align="center"><strong>T&iacute;tulo </strong></div>
          <td colspan=2> <div align="center"><strong>Acciones</strong></div></td>
          <?php

conectarse();
// CONSULTAMOS TODOS LO REGISTRO PARA SABER CUANTOS TENEMOS
//$result = mysql_query("SELECT notifec,notisec,notitit FROM noti where notifec > " . $desde . " or notifec <" .$hasta. "order by notifec");


// TRAEMOS SOLOS LOS REGISTROS QUE ENTRAN EN EL LIMITE ESPECICADO ARRIBA, OJO DEPENDIENDO DE LA PAGINA DONDE ESTOY
$fecha_inicio=$_POST['fecha_inicio']; 
$fecha_fin=$_POST['fecha_fin']; 
$result = mysql_query("SELECT * FROM noti WHERE notifec BETWEEN '$fecha_inicio' AND '$fecha_fin'");
$total_paginas = ceil($total_registros / $registros); 
$total_registros = mysql_num_rows($result); 

if($total_registros) {

		  echo "<tr bgcolor='#99CCCC'> <font size='4'>";
		  echo "Sección: -" .$seccide. "-  ";
		  $query = mysql_query("SELECT * FROM secc WHERE seccide = '$seccide'");
		  while ($myrows = mysql_fetch_array($query)) {
		  	echo $myrows['seccdes'];}
			echo "</font></tr><br>";


	while ($myrow = mysql_fetch_array($result)) {
		echo "<tr>";
	
		echo "<td width='9%' align='center'><font size='2'>";
		echo $myrow["notifec"];
		echo "</font></td>";
	
		echo "<td align='center'><font size='2'>";
		$query = mysql_query("SELECT * FROM secc WHERE seccide = '$seccide'"); 
		while ($myrows = mysql_fetch_array($query)) {
			echo $myrows["seccdes"];}
		echo "</font></td>";
		
		
		
		echo "<td>";
		echo $myrow["notitit"];
		echo "</td>";
	
		echo "<td>";
		echo "<a href=modif_noticias.php?notiide=".$myrow["notiide"] ."&". "seccdes=".$myrow["notitit"] . ">Modificar</a><br>";
		echo "</td>";
	
		echo "<td>";
		echo "<a href=borrar_secciones.php?seccide=".$myrow["notiide"].">Borrar</a><br>";
		echo "</td>";
	
		echo "</tr>";
	
		}
	} else {
		echo "<tr><td colspan=3><font color='darkgray'>(sin resultados)</font></td></tr>";
	}
	
	mysql_free_result($result);				
	
	if($total_registros) {
		
		echo "<center>";
		
		if(($pagina - 1) > 0) {
			echo "<a href='lista_noticias_x_fecha.php?pagina=".($pagina-1)."&notifec >" .$desde . "or &notifec < " .$hasta."'>< Anterior</a> ";
		}
		
		for ($i=1; $i<=$total_paginas; $i++){ 
			if ($pagina == $i) {
				echo "<b>".$pagina."</b> "; 
			}else{
				echo "<a href='lista_noticias_x_fecha.php?pagina=$i" . "&notifec >" .$desde . "or &notifec < " .$hasta."'>$i</a> "; }
		}
	  
		if(($pagina + 1)<=$total_paginas) {
			echo " <a href='lista_noticias_x_fecha.php?pagina=".($pagina+1) . "&notifec >" .$desde . "or &notifec < " .$hasta."'>Siguiente ></a>";
		}
		
		echo "</center>";
		
	}
?>
      </table>
      <br>
    </td>
  </tr>

  <tr> 
    <td valign="top" bordercolor="#CCCCCC" bgcolor="#99CCCC">&nbsp;</td>
    <td valign="top">&nbsp; </td>
  </tr>
</table>
<tr bgcolor="#99CCCC"> 
    <td height="50" colspan="2"><div align="center"></div></td>
</tr>
<tr>
  <td width="82%" valign="top"><tr>
__________________
:stress: Patri:corazon:
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:34.