方法pot-php、mysqli和fpdf

方法pot-php、mysqli和fpdf,php,html,Php,Html,我尝试使用FPDF制作报告 将表单数据发送到FPDF中的查询时,不会显示数据 形式 您的帐户不发送表单数据。您可以使用Jquery将需要的数据发送到PDF模板 include_once('PDF.php'); require 'conexion.php'; $where = ""; if (isset($_POST['buscar'])) { $desde = date('Y-m-d',strtotime ($_POST['desde'])); //$hasta = date('Y-m-d'

我尝试使用FPDF制作报告

将表单数据发送到FPDF中的查询时,不会显示数据

形式

您的帐户不发送表单数据。您可以使用Jquery将需要的数据发送到PDF模板

include_once('PDF.php');
require 'conexion.php';

$where = "";

if (isset($_POST['buscar'])) {
$desde = date('Y-m-d',strtotime ($_POST['desde']));
//$hasta = date('Y-m-d', strtotime($_POST['hasta']));
$valor = $_POST['campo'];
if (empty($_POST['dese'])) {
$where = "WHERE proveedores LIKE '%".$valor."%' ORDER BY cxl ASC";
} elseif (empty($POST['campo'])) {
$where = "WHERE f_elaboracion = '".$desde."' ORDER BY cxl ASC";
}else{
$where = "WHERE proveedores LIKE '".$valor."' AND f_elaboracion = '".$desde."' ORDER BY cxl ASC";
}
}

$sql = "SELECT * FROM retensiones $where";
$resultado = $mysqli->query($sql);?>
<html lang="es">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<Script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<Script type="text/javascript">
$(document).ready(function () {
$("#indexPDF").click(function(){
submit('indexpdf.php', 'POST', [
{ name: 'desde', value: $('#desde').val() },
{ name: 'campo', value: $('#campo').val() }
], '_blank');
});
});

function submit(action, method, values, target) {
var form = $('<form/>', {
action: action,
method: method,
target: target
});
$.each(values, function() {
form.append($('<input/>', {
type: 'hidden',
name: this.name,
value: this.value
}));    
});
form.appendTo('body').submit();
}
</SCRIPT>
</head>
<body>
<div class="container">
<div class="row">
<h2 style="text-align:center">FORMULARIO</h2>
</div>
<div class="row">
<form  method="POST" >
<select name="campo">
<option value="2">Proveedor</option>
<?php
$query = $mysqli -> query ("SELECT proveedores FROM proveedores ORDER BY proveedores ASC");  
while ($valores = mysqli_fetch_array($query)) {
echo '<option value="'.$valores[proveedores].'">'.$valores[proveedores].'</option>';
}?>
</select>
<td>Desde :&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td><input type="date" id="desde" name="desde"/></td>
<button name="buscar" type="submit"   class="btn btn-info" >Buscar</button>
<td width="200"><div id="indexPDF" class="btn btn-danger">Exportar Busqueda a PDF</div></td>
</form>
</div>
<div class="row table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>CXL</th>
<th>FECHA</th>
<th>Concepto</th>
<th>Periodo</th>
<th>Importe</th>
<th>I.V.A.</th>
<th>I.S.R.</th>
</tr>
</thead>
<tbody>
<?php while($row = $resultado->fetch_array(MYSQLI_ASSOC)) 
{?>
<tr>
<td><?php echo $row['cxl']; ?></td>
<td><?php echo date('d/m/Y',strtotime($row['f_elaboracion'])); ?></td>
<td><?php echo $row['concepto']; ?></td>
<td><?php echo $row['periodo']; ?></td>
<td><?php echo number_format (($row['importe']),'2','.',','); ?></td>
<td><?php echo number_format (($row['iva']),'2','.',','); ?></td>
<td><?php echo number_format (($row['isr']),'2','.',','); ?></td>
</tr>
<?php 
}?>
</tbody>
</table>
</div>
</div>      
</body>
</html> 
我更改了你的密码

<a target="_blank" href="indexpdf.php" class="btn btn-danger">Exportar Busqueda a PDF</a>

缺少的是样式表。我编辑了上面的代码以包含样式表

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

非常感谢,我不知道它们是否用于脚本,但我没有看到按钮导出搜索到PDF,我不尊重引导设计我不知道我是否运行良好,但至少按钮作为纯文本吸引我,我不知道那是什么?我也试着在没有引导的情况下运行,但它的工作原理是一样的,我按照您的指示运行,没有引导,只有您放置的SCRPT,但我不知道为什么该按钮没有出现缺少的部分是CSS引用。请再次查看代码,我已经添加到上面的代码中。我也添加了扩展名,但“导出到PDF”按钮不起任何作用,我按了它,但它什么也没做,你认为它应该这样做吗?你是准确复制了我发布的代码还是更改了它?
<a target="_blank" href="indexpdf.php" class="btn btn-danger">Exportar Busqueda a PDF</a>
<div id="indexPDF" class="btn btn-danger">Exportar Busqueda a PDF</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">