Foros del Web » Programando para Internet » PHP »

Consulta MYSQL con ROLLUP en PHP

Estas en el tema de Consulta MYSQL con ROLLUP en PHP en el foro de PHP en Foros del Web. Hola, agradeceria me pueda ayudar con un problema. He creado una consulta en mysql que muestra subtotales con ROLLUP. Sin embargo cuando intento mostrar los ...
  #1 (permalink)  
Antiguo 28/06/2011, 23:04
 
Fecha de Ingreso: febrero-2008
Mensajes: 9
Antigüedad: 16 años, 2 meses
Puntos: 0
Consulta MYSQL con ROLLUP en PHP

Hola, agradeceria me pueda ayudar con un problema.

He creado una consulta en mysql que muestra subtotales con ROLLUP. Sin embargo cuando intento mostrar los datos en una tabla a traves de php no funciona, pero en mysql directamente si lo hace.

la query que he creado es la siguiente:

SELECT IFNULL(detalle_monto,Total) as detalle_monto, IFNULL(forma_de_pago,Total) as forma_de_pago, SUM(haber) AS detallehaber FROM movimientos GROUP BY detalle_monto, forma_de_pago WITH ROLLUP

En php el codigo que utilizo es el siguiente:


<?php require_once('Connections/test.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_test, $test);
$query_Recordset2 = "SELECT IFNULL(detalle_monto,"Total"), IFNULL(forma_de_pago,"Total"), SUM(haber) FROM movimientos GROUP BY detalle_monto, forma_de_pago WITH ROLLUP";
$Recordset2 = mysql_query($query_Recordset2, $test) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

mysql_free_result($Recordset2);
?>

me dice que hay un error en la linea 35 que es la que contiene la query...($query_Recordset2)
  #2 (permalink)  
Antiguo 28/06/2011, 23:47
Avatar de Sourcegeek
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: $mex['B.C.'];
Mensajes: 1.816
Antigüedad: 15 años
Puntos: 322
Respuesta: Consulta MYSQL con ROLLUP en PHP

Y... Tenemos que adivinar el error también? =/
__________________
Buscas desarrollador web? Sourcegeek. Diseño web, Maquetación y Programación
¡Escribe bien! Esto es un foro, no un Facebook para que escribas con los pies

Etiquetas: mysql, rollup, subtotales
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:16.