Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/01/2013, 05:33
ilem
 
Fecha de Ingreso: abril-2007
Mensajes: 6
Antigüedad: 17 años
Puntos: 0
Reporte entre fechas

Hola Buenas. Soy nuevo en php y tengo una duda que me está llevando de cabeza.
Estoy montando un pequeño sistema para llevar recaudaciones de clientes, y no logro hacer las consultas entre fechas, seguramente por que estén mal ejecutadas.
El caso es que no se ya por donde tirar, creo que he probado con todas las combinaciones de sintaxis posibles y sigue sin funcionar.
Os explico. De un formulario recojo date1 y date2 como fechas de inicio y fin para la consulta. También recojo el nombre de cliente. Pues bien quisiera que se mostraran los datos de recaudaciones de ese cliente en ese rango de fechas. El codigo para tal lo tengo de la siguiente manera:
<table width="800" border="0" align="center" >

<tr>
<td width="220" align="right"><a href='selector.php'><img src="images/back.png" width="32" height="32" border="0" /></a></td>
<td width="220">&nbsp;</td>
<td align="right"><a href='logout.php'><img src="images/exit.png" width="32" height="32" border="0" /></a></td>
</tr>

<?php

echo"<tr>";
echo"<td align='center'><h3>Informes de Clientes</h3></td>";
echo"</tr>";
echo"</table>";
echo"<br>";

include "funciones.php";

$conex=conectar();
$fecha1=$_POST['date1'];
$fecha2=$_POST['date2'];
$cliente=$_POST['nom_cli'];
$sql2="SELECT * from recaudaciones WHERE fec_rec BETWEEN '$fecha1' and '$fecha2' AND nom_cli='$cliente'";
$result2=mysql_query($sql2, $conex) or die("Error en $sql2 <br>Mysql dice:".mysql_error());



$total=0;
while($array_rec=mysql_fetch_array($result2)){
echo"<table width='800' align='center' >";
echo"<tr>";
echo"<td><input type='text' name='fechas' value='$array_rec[3]' /></td>";
echo"<td><input type='text' name='cliente' size='40' value='$array_rec[1]'/></td>";
echo"<td><input type='text' name='maquina' size='40' value='$array_rec[2]'/></td>";
echo"<td><input type='text' name='euros' size='12' value='$array_rec[4]'/></td>";
echo"</tr>";
echo"<tr>";
echo"<td></td>";
echo"<td width='350'></td>";
echo"</tr>";
echo"</table>";
$total+=$array_rec[4];
}
echo"<table width='700' align='center'>";
echo"<tr>";
echo"<td width='200'></td>";
echo"<td width='295'></td>";
?>
<td>Total Euros<input type='text' name='totalsuma' size='12' value=' <? echo $total; ?>'/></td>
<?php
echo"</tr>";
echo"</table>";

mysql_close();
echo"<br>";
echo"<br>";
?>



Alguna sugerencia?