Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/03/2014, 13:31
novapi89
 
Fecha de Ingreso: septiembre-2013
Mensajes: 8
Antigüedad: 10 años, 7 meses
Puntos: 0
Respuesta: como realizar un rango de fecha

Mira la verdad no he entendido muy bien lo que me quisiste explicar, aca dejo el codigo para que me ayudes a ver donde tengo el error

<h2>Ingrese fecha a buscar</h2><br>
<form method="post" action="buscarventas.php">
Desde:<input type="text" name="fecha1" value="aaaa-mm-dd" >
Hasta:<input type="text" name="fecha2" value="aaaa-mm-dd" >
<br >
<input type="submit" name="submit" value="Buscar" />
</form>

<?
include ('conexion.php');
$desde=$_POST['fecha1'];
$hasta=$_POST['fecha2'];

$re=mysql_query("select * from ventas where fecha BETWEEN '$hasta' AND '$desde' order by id ASC");
?>

<table width="454" height="66" border="1">
<tr>
<td width="85">FECHA</td>
<td>VENDEDOR</td>
<td width="101">NOMBRE</td>
<td width="98">DETALLE</td>
<td width="59">CANT.</td>
<td width="77">SUBTOTAL</td>
</tr>
<?
while($f=mysql_fetch_array($re)){

$subtotal=$f['subtotal'];
$cant=$f['cantidad'];
$nombre=$f['nombre'];
$detalle=$f['detalle'];
$fecha=$f['fecha'];
$vendedor=$f['vendedor'];

$arreglo[]=array('Vendedor'=>$vendedor,
'Cantidad'=>$cant,
'Subtotal'=>$subtotal);
?>
<tr>
<td><? echo $fecha;?></td>
<td><? echo $vendedor; ?></td>
<td><? echo $nombre; ?></td>
<td><? echo $detalle;?></td>
<td><? echo $cant;?></td>
<td> $ <? echo $subtotal;?></td>
</tr>
<?

}
$subt=0;
$cantidad=0;

for($i=0;$i<count($arreglo);$i++){
$subt=($arreglo[$i]['Subtotal'])+$subt;
$cantidad=($arreglo[$i]['Cantidad'])+$cantidad;
}

echo "</table><br><h3>
Cantidad de productos vendidos: ".$cantidad."<br>
Total ventas: $".$subt."</h3>";
echo "----------------------------------------------------------------------------- <br>";

$subtotal=0;
$cantidad=0;

for($i=0;$i<count($arreglo);$i++){
if($arreglo[$i]['Vendedor']=='mauro')
{
$subtotal=($arreglo[$i]['Subtotal'])+$subtotal;
$cantidad=($arreglo[$i]['Cantidad'])+$cantidad;
}
}

echo 'El vendedor: Mauro<br>';
echo 'Cantidad de productos vendidos: '.$cantidad.'<br>';
echo 'Total: $'.$subtotal."<br>";
echo "--------------------------------- <br>";
?>
</table>