0
I am trying to generate a PDF with data sent via POST. insert link description here
The os-list.php file is a report that the data changes according to the filter. I am sending this data but only appears the last record.
0
I am trying to generate a PDF with data sent via POST. insert link description here
The os-list.php file is a report that the data changes according to the filter. I am sending this data but only appears the last record.
1
Your inputs have names
repeated in each row
<input type="hidden" name="OSid" value="<?=$OSid?>" />
In this case when you send the POST the browser will send only the last read value, the last page Names.
If you do the Names as arrays
:
<input type="hidden" name="OSid[]" value="<?=$OSid?>" />
The $_POST['OSid']
will be a list of all ids sent, and so with all names
.
EDIT adding implementation
To generate multi-line report:
<?php
// Cada um desses valores agora é um array
$OSid = $_POST['OSid'];
$dataHora = $_POST['dataHora'];
$nomeFantasia = $_POST['nomeFantasia'];
$NomeSetor = $_POST['NomeSetor'];
$motivoOs = $_POST['motivoOs'];
$TotalMaterial = $_POST['TotalMaterial'];
$NomeTipoOS = $_POST['NomeTipoOS'];
$status = $_POST['status'];
$corpo_pagina = "
<html>
<head>
<link href='css/bootstrap.css' media='print' rel='stylesheet'>
<link href='css/estiloOS.css' media='print' rel='stylesheet' >
</head>
<boby>
<table border='1' class='table table-striped'>
<tr>
<th>ID</th>
<th>DATA</th>
<th>CLIENTE</th>
<th>SETOR</th>
<th>MOTIVOS OS</th>
<th>CUSTO TOTAL</th>
<th>TIPO OS</th>
<th>STATUS</th>
</tr>";
// Fazemos um laço pelo número de itens da lista
// $OSid e imprimimos cada item em uma linha separada
for( $i = 0; $i < count( $OSid ); $i++ ) {
$corpo_pagina .= "
<tr>
<td>".$OSid[$i]."</td>
<td>".$dataHora[$i]."</td>
<td>".$nomeFantasia[$i]."</td>
<td>".$NomeSetor[$i]."</td>
<td>".$motivoOs[$i]."</td>
<td>".$TotalMaterial[$i]."</td>
<td>".$NomeTipoOS[$i]."</td>
<td>".$status[$i]."</td>
</tr>";
}
$corpo_pagina .= "</table>";
Browser other questions tagged php mpdf
You are not signed in. Login or sign up in order to post.
Nothing wrong there in this array, no. Is returning the word array in all of them.
– fabricio_wm
You must have to change the way the data is entered in the table. If you only use
echo
orprint
he printsArray
. Now you need to reference the keys to print the correct value. Ex.: https://eval.in/680884– Ricardo Moraleida
<td><? php $Osid = array(); $Osid[] = $os['id']; foreach($Osid as $valor_OSid): print_r($valor_OSid ); ? > <input type="Hidden" name="Osid[]" value="<?= $valor_OSid? >" /> <?php endforeach; ? > </td> Is displaying in the list but the pdf only appears the word array. Thanks.
– fabricio_wm
I edited the reply by adding the implementation in the output of the report. The code you are showing believe that is the table on the screen, but the principle is the same.
– Ricardo Moraleida
I made the changes but is giving error when generating PDF document. I updated Gits. You said value is
value="<?=$OSid?>"
That’s right? Pq is theforeach($OSid as $valor_OSid):
It would not be thevalue="<?=$valor_OSid?>"
?– fabricio_wm
https://gist.github.com/FabricioYwin/843377a186cc083887110bef057f007d
– fabricio_wm
what error is giving?
– Ricardo Moraleida
Failed to Generate PDF document. Reload? Ai If you click, nothing happens.
– fabricio_wm
Look at the print, pfv. http://imgur.com/a/Mgx5U
– fabricio_wm
Let’s go continue this discussion in chat.
– Ricardo Moraleida