Foros del Web » Creando para Internet » Herramientas y Software »

Crear pdf de tabla de resultados deuna consulta

Estas en el tema de Crear pdf de tabla de resultados deuna consulta en el foro de Herramientas y Software en Foros del Web. Buenas Tardes. Otra vez estoy acá para sus consejos, tengo una tabla con resultados de una consulta, y desearía poder transformarlo a pdf, (está hecho ...
  #1 (permalink)  
Antiguo 12/09/2010, 17:20
Avatar de germancerda  
Fecha de Ingreso: mayo-2008
Mensajes: 43
Antigüedad: 15 años, 11 meses
Puntos: 0
Crear pdf de tabla de resultados deuna consulta

Buenas Tardes.

Otra vez estoy acá para sus consejos, tengo una tabla con resultados de una consulta, y desearía poder transformarlo a pdf, (está hecho en dreamw) la verdad no he podido hacerlo, y como soy bien novato en esto agradezco que me ayuden con la explicación más sencilla...
Este es el código que uso.
<?php require_once('Connections/con_mysql.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;
}
}

$colname_Recordset1 = "-1";
if (isset($_GET['NUM_BUNCH'])) {
$colname_Recordset1 = $_GET['NUM_BUNCH'];
}
mysql_select_db($database_con_mysql, $con_mysql);
$query_Recordset1 = sprintf("SELECT NUM_BUNCH, COD_VARIE, NUM_TALLOS, PRECIO FROM bunche WHERE NUM_BUNCH = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $con_mysql) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = "-1";
if (isset($_GET['NUM_PACK'])) {
$totalRows_Recordset1 = $_GET['NUM_PACK'];
}
mysql_select_db($database_con_mysql, $con_mysql);
$query_Recordset1 = sprintf("SELECT NUM_PACK, COD_VARIE, PRECIO, SUM(NUM_TALLOS) AS TOTAL_TALLOS, sum(precio*num_tallos) as total FROM bunche WHERE NUM_PACK = %s GROUP BY COD_VARIE", GetSQLValueString($totalRows_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $con_mysql) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$maxRows_Recordset2 = 10;
$pageNum_Recordset2 = 0;
if (isset($_GET['pageNum_Recordset2'])) {
$pageNum_Recordset2 = $_GET['pageNum_Recordset2'];
}
$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;

$totalRows_Recordset2 = "-1";
if (isset($_GET['NUM_PACK'])) {
$totalRows_Recordset2 = $_GET['NUM_PACK'];
}
mysql_select_db($database_con_mysql, $con_mysql);
$query_Recordset2 = sprintf("SELECT round(sum((precio*num_tallos)),2),cod_varie as total FROM bunche WHERE num_pack= %s", GetSQLValueString($totalRows_Recordset2, "int"));
$query_limit_Recordset2 = sprintf("%s LIMIT %d, %d", $query_Recordset2, $startRow_Recordset2, $maxRows_Recordset2);
$Recordset2 = mysql_query($query_limit_Recordset2, $con_mysql) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);

if (isset($_GET['totalRows_Recordset2'])) {
$totalRows_Recordset2 = $_GET['totalRows_Recordset2'];
} else {
$all_Recordset2 = mysql_query($query_Recordset2);
$totalRows_Recordset2 = mysql_num_rows($all_Recordset2);
}
$totalPages_Recordset2 = ceil($totalRows_Recordset2/$maxRows_Recordset2)-1;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<p><img src="images/logo.gif" width="160" height="102" /></p>
<table border="1">
<tr>
<td>Packing</td>
<td>Variedad</td>
<td>Precio</td>
<td>Total</td>
<td>Tallos</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['NUM_PACK']; ?></td>
<td><?php echo $row_Recordset1['COD_VARIE']; ?></td>
<td><?php echo $row_Recordset1['PRECIO']; ?></td>
<td><?php echo $row_Recordset1['total']; ?></td>
<td><?php echo $row_Recordset1['TOTAL_TALLOS']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<p>&nbsp;</p>
<table border="1">
<tr>
<td>Total</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset2['round(sum((precio*num_tallos)),2)']; ?></td>
</tr>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);

mysql_free_result($Recordset2);
?>



Agradezco las ayudas

Etiquetas: editores-web, pdf, resultados, tablas
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 05:11.