Cita:
if (isset($_POST['vende']) && isset($_POST['fechain'])&& isset($_POST['fechaf'])) {
$FI = $_POST['fechain'];
$FF = $_POST['fechaf'];
$ven = $_POST['vende'];
$producto = "1";
$consulta= "SELECT C.cod_cte, C.razon_social, isnull((select top 1 fecha from entysal where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion in ('36','37','38') order by fecha desc),'') as ultima_venta, isnull((select top 1 fecha from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc),'') as ultima_pedido, isnull((select sum(cantidad) from entysal where folio in (select top 1 folio from entysal where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion in ('36','37','38') order by fecha desc)),0.0) as cantidad_venta, isnull((select sum(cantidad_pedida) from mpedcte where folio in (select top 1 folio from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc)),0.0) as cantidad_pedido, isnull((select status from pedcte where folio in (select top 1 folio from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc)),'') as status_pedido FROM CLIENTES C where vendedor = '@vendedor'" ;
$consulta = str_replace('@FI',$FI,$consulta);
$consulta = str_replace('@FF',$FF,$consulta);
$consulta = str_replace('@vendedor',$ven,$consulta);
$consulta = str_replace('@producto',$producto,$consulta);
}
?>
$FI = $_POST['fechain'];
$FF = $_POST['fechaf'];
$ven = $_POST['vende'];
$producto = "1";
$consulta= "SELECT C.cod_cte, C.razon_social, isnull((select top 1 fecha from entysal where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion in ('36','37','38') order by fecha desc),'') as ultima_venta, isnull((select top 1 fecha from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc),'') as ultima_pedido, isnull((select sum(cantidad) from entysal where folio in (select top 1 folio from entysal where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion in ('36','37','38') order by fecha desc)),0.0) as cantidad_venta, isnull((select sum(cantidad_pedida) from mpedcte where folio in (select top 1 folio from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc)),0.0) as cantidad_pedido, isnull((select status from pedcte where folio in (select top 1 folio from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc)),'') as status_pedido FROM CLIENTES C where vendedor = '@vendedor'" ;
$consulta = str_replace('@FI',$FI,$consulta);
$consulta = str_replace('@FF',$FF,$consulta);
$consulta = str_replace('@vendedor',$ven,$consulta);
$consulta = str_replace('@producto',$producto,$consulta);
}
?>
Cita:
Y ME MANDA EL SIGUIENTE ERROR<?php
$result = mssql_query($consulta);
while( $row = mssql_fetch_array( $result ) ){
//cierra mas abajo ?>
$result = mssql_query($consulta);
while( $row = mssql_fetch_array( $result ) ){
//cierra mas abajo ?>
Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\areacomercial.starfruts.com.mx\vend edor01.php on line 124
Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\areacomercial.starfruts.com.mx\vend edor01.php on line 125