Home » Php » php – Only the previous data submited gets printed

php – Only the previous data submited gets printed

Posted by: admin February 25, 2020 Leave a comment

Questions:

Regards to any reader.
i have this table, wich is inside a panel. the purpose of it is to send selected data to the printer with checkboxes on data from a query, but somehow it only prints 1 row of the table and only print it after the next single row is printed.

lets say, i press print with the “A” row selected but nothing happens, after that i print the “B” row the “A” row gets print. And not only that, if i dare to Print “A” and “B” rows together, nothing will be printed, not even on the second try.
now sure if this is normal but, all the selected rows goes into another table to get print, but this other table is not visible to the user. jus to make the data por “easy to read”, this is where enters the second query.

Any idea of why this could happens?
the table worked just fine when isolated, but when i put it in the panel it stop working correctly.
Any help will be appreciated.

<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs bordered">

<li class="active">
<a href="#V1" data-toggle="tab">
<span class="visible-xs"><i class="entypo-home"></i></span>
<span class="hidden-xs"><?php echo get_phrase('Vts 1'); ?></span>
</a>
</li>

<li>
<a href="#V2" data-toggle="tab">
<span class="visible-xs"><i class="entypo-user"></i></span>
<span class="hidden-xs"><?php echo get_phrase('Vts - A'); ?></span>
</a>
</li>

<li>
<a href="#TLL" data-toggle="tab">
<span class="visible-xs"><i class="entypo-user"></i></span>
<span class="hidden-xs"><?php echo get_phrase('Taller'); ?></span>
</a>
</li>
</ul>

<div class="tab-content">

<div class="tab-pane active" id="V1"> </div> <---- table number 1

<div class="tab-pane" id="V2"> </div> <----- table number 2

<div class="tab-pane" id="TLL">  <---------- the infamous table  -----------
  <form id="tabtab" method="POST">
   <table class="table table-bordered" style="color: Black" id="table-3">
<thead>
<tr>
<th> headers </th>
</tr>
</thead>

<tbody>
<?php
$control_info    = $this->db->query("select * from controlsemanal where vendedora = 'Taller' and Indicador != '1' and Indicador !='100' ORDER BY FIELD (Id_Status,1,3,4,5,6,2,7,0) ");
$arr_loop = $control_info;

foreach ($arr_loop->result_array() as $row) {
<tr>
<td>
 <input type="checkbox" name="check[]" value="<?php echo $row['Referencia']; ?>">
</td>
<more data over here>
<?php } ?>
</tbody>
</table>

<div style="display:none" id="printme3">
<table border="1" style="color: Black; border-collapse: collapse;height:100px">
<tr> Headers </tr>
<?php
$Referencia = (isset($_POST['check'])) ? implode(', ', $_POST['check']) : '';


*$control_info    = $this->db->query("select * from controlsemanal where vendedora = 'Tall' and **Referencia = ('$Referencia')**  ORDER BY FIELD (Id_Status,1,3,4,5,6,2,7,0) ");*
foreach ($control_info->result_array() as $row) {
 <SELECTED ROWS GETS FORMAT OVER HERE>
<?php } ?>
</table>
</div>

<center>
<button style="border:0;background:#04998A;color:white;width: 550px;height:50px;font-size: 30px" onclick="imprimir3();">
<b>PRINT</b>
</button>
</center>
</form>
</div>


And this is the print function

function imprimir3() {
var objeto = document.getElementById('imprimeme3');
var ventana = window.open('', '_blank'); 
ventana.document.write(objeto.innerHTML);
ventana.document.close(); 
ventana.print();
ventana.close();
}
How to&Answers: