¿Como obtener variables para generar pdf doompdf?
Publicado por Alejandro (5 intervenciones) el 11/09/2018 06:14:55
necesito su ayuda necesito obtener las variables $valueToSearch y $valueToSearch2 del archivo busqueda.php , al archivo pdf_consumidor.php ,me dijeron que usara require_onde o include pero la verdad soy principiante y no tengo mucha idea de como usarlos correctamente...
busqueda.php
pdf_consumidor.php
busqueda.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
$valueToSearch2 = $_POST['valueToSearch2'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM facturacion where item_mes LIKE '$valueToSearch' AND item_anio LIKE '$valueToSearch2' ORDER BY 'item_dia' ASC";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `facturacion`";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
$connect = mysqli_connect("localhost", "root", "", "registrador");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP HTML TABLE DATA SEARCH</title>
<style>
table,tr,th,td
{
border: 1px solid black;
}
</style>
</head>
<body>
<form action="busqueda.php" method="post">
<input type="text" name="valueToSearch" value="<?php echo array_key_exists('valueToSearch', $_POST) ? $_POST['valueToSearch'] : ''; ?>" placeholder="Ingrese Mes"><br><br>
<input type="text" name="valueToSearch2" value="<?php echo array_key_exists('valueToSearch2', $_POST) ? $_POST['valueToSearch2'] : ''; ?>" placeholder="Ingrese Año"><br><br>
<input type="submit" name="search" value="Filter"><br><br>
<button type="button" <li><a href="pdf_consumidor.php" Excel class="btn btn-info">PDF</a></li> </button>
<table>
<tr>
<th>Sujetas</th>
<th>Agravadas</th>
</tr>
<!-- populate table from mysql database -->
<?php
while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['item_gravadas'];?></td>
<td><?php echo $row['item_total'];?></td>
</tr>
<?php endwhile;?>
</table>
</form>
</body>
</html>
pdf_consumidor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require_once("dompdf/dompdf_config.inc.php");
$conexion = mysql_connect("localhost","root","");
mysql_select_db("registrador",$conexion);
$codigoHTML='
<!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>CONSUMIDOR</title>
</head>
<body>
<div align="center">
<img src="" width="100px" height="100px">
<H2>CONSUMIDOR</H2>
<table width="100%" border="1">
<tr>
<td bgcolor="#0099FF"><strong>Ventas Gravadas.</strong></td>
<td bgcolor="#0099FF"><strong>Total de ventas</strong></td>
</tr>';
$consulta=mysql_query("SELECT * FROM facturacion");
while($dato=mysql_fetch_array($consulta)){
$codigoHTML.='
<tr>
<td>'.$dato['item_gravadas'].'</td>
<td>'.$dato['item_total'].'</td>
</tr>';
}
$codigoHTML.='
</table>
<img src="" width="100px" height="100px">
</div>
</body>
</html>';
$codigoHTML=utf8_decode($codigoHTML);
$dompdf=new DOMPDF();
$dompdf->load_html($codigoHTML);
ini_set("memory_limit","128M");
$dompdf->render();
$dompdf->stream("Consumidor_final.pdf");
?>
Valora esta pregunta


0