Cita:
Iniciado por catpaw Puedes ponder todo el bucle para poder ayudarte mejor
Claro, aqui esta
Código PHP:
<?php
include_once "../Class/conexion2.php";
@$f = $_REQUEST['datepicker'];
$sql="SELECT FechaEmision,
(SELECT Nombre FROM Sucursal WHERE (Sucursal = VentasSucursal.Sucursal)) AS NombreSucursal,
CONVERT (VarChar, Sucursal) AS Sucursal,
ROUND(VentaActual / 1000, 3) AS VentaActual,
ROUND(VentaAnoAnt / 1000, 3) AS VentaAnoAnt,
ROUND(VentaBisAnt / 1000, 3) AS VentaBisAnt,
ROUND(VentaDiaAnt / 1000, 3) AS VentaDiaAnt,
ROUND(VentaSemAnt / 1000, 3) AS VentaSemAnt
FROM VentasSucursal WHERE (FechaEmision = '$f')";
$resultado=odbc_exec($conn,$sql);
while($row=odbc_fetch_array($resultado))
{
$x = $row['VentaBisAnt'];
$y = $row['VentaAnoAnt'];
$z = $row['VentaActual'];
$rs = $y - $x;
@$rs2 = (1-$x/$y)*100;
$rs3=$z-$y;
@$cr = (1-$y/$z)*100;
@$suma = $suma + $row['VentaActual'];
@$porP = $row['VentaActual'] / $suma * 100;
echo "<tr>";
//echo "<td>",$suma,"</td>";
echo "<td>",$row['Sucursal'],"</td>";
echo "<td>",utf8_encode($row['NombreSucursal']),"</td>";
echo "<td>",round($row['VentaBisAnt'],2),"</td>";
echo "<td>",round($row['VentaAnoAnt'],2),"</td>";
echo "<td>",round($row['VentaSemAnt'],2),"</td>";
echo "<td>",round($row['VentaDiaAnt'],2),"</td>";
echo "<td>",round($row['VentaActual'],2),"</td>";
if($rs > 0)
{
echo "<td>",round($rs,2),"</td>";
}
else
{
echo "<td><font color=red>",round($rs,2),"</font></td>";
}
if($porP > 0)
{
echo "<td>",round($porP,3),"</td>";
}
else
{
echo "<td><font color=red>",round($porP,3),"</font></td>";
}
if($rs3 < 0)
{
echo "<td><font color=red>",round($rs3,2),"</font></td>";
}
else
{
echo "<td>",round($rs3,2),"</td>";
}
if($cr < 0)
{
echo "<td><font color=red>",round($cr,2),"</font></td>";
}
else
{
echo "<td>",round($cr,2),"</td>";
}
echo "</tr>";
}
?>