Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/08/2014, 15:43
Avatar de asus090102
asus090102
 
Fecha de Ingreso: mayo-2012
Ubicación: Ensenada- Buenos Aires
Mensajes: 67
Antigüedad: 12 años
Puntos: 1
Buscador, si no hay nada entonces es todo

Hola amigazos, estoy haciendo un buscador y se me presenta este problema:

Código HTML:
<form name="form1" method="post" action="">
<table><tr>
<td><label for="txt1"><b>Interno:</label></td><td>
<input type="text" name="txt1" /></td>
<td><label for="txt2"><b>Desde:</b></label></td><td>
<input type="text" name="txt2" /></td>
<td><label for="txt3"><b>Hasta:</b></label></td><td>
<input type="text" name="txt3" /></td>
<td><input type="submit" name="btn" id="btning" value="CONSULTAR" /></td></tr>
</table>
</form> 
Código PHP:
$interno=$_POST["txt1"];

$desde=$_POST["txt2"];
if (
$desde==""){
$desde="20000101";
}

$hasta=$_POST["txt3"];
if (
$hasta==""){
$hasta=date("Y,m,d");
}

$rst mysql_query("SELECT * FROM tabla1 WHERE interno=" $interno " and fecha between '".$desde."' and '".$hasta."'",$conexion);
?> 
Código HTML:
<table>
<tr>
<td>INGRESO</td>
<td>FECHA</td>
<td>INTERNO</td>		
</tr> 
Código PHP:
<?php
while ($fila=  mysql_fetch_array($rst))
{
?>
Código HTML:
<td><?php echo$fila["id"];?></td>
<td><?php echo$fila["fechae"];?></td>
<td><?php echo$fila["interno"];?></td>
</tr> 
Código PHP:
<?php
}
?>
Código HTML:
</table> 
Obviamente "solo" me da los resultados obtenidos siempre y cuando introduzca un número de interno.
Pero ¿Qué tendría que hacer para que: En el caso de que no le introduzca un número de interno me devuelva todos los resultados entre las fechas solicitadas?
Desde ya muchas gracias por la ayuda.