I am new in this of the fixes, and I want to know how to go through them correctly to make an insertion of data based on the contents of a table, how should the code be to execute the corresponding queries?:
SaveFactura.php
<?php
$htmlContent = file_get_contents("FrmClientes.php");
$DOM = new DOMDocument();
$DOM->loadHTML($htmlContent);
$Header = $DOM->getElementsByTagName('th');
$Detail = $DOM->getElementsByTagName('td');
//#Get header name of the table
foreach($Header as $NodeHeader)
{
$aDataTableHeaderHTML[] = trim($NodeHeader->textContent);
}
print_r($aDataTableHeaderHTML); die();
//#Get row data/detail table without header name as key
$i = 0;
$j = 0;
foreach($Detail as $sNodeDetail)
{
$aDataTableDetailHTML[$j][] = trim($sNodeDetail->textContent);
$i = $i + 1;
$j = $i % count($aDataTableHeaderHTML) == 0 ? $j + 1 : $j;
}
print_r($aDataTableDetailHTML); die();
//#Get row data/detail table with header name as key and outer array index as row number
for($i = 0; $i < count($aDataTableDetailHTML); $i++)
{
for($j = 0; $j < count($aDataTableHeaderHTML); $j++)
{
$aTempData[$i][$aDataTableHeaderHTML[$j]] = $aDataTableDetailHTML[$i][$j];
}
}
$aDataTableDetailHTML = $aTempData; unset($aTempData);
print_r($aDataTableDetailHTML); die();
?>
FrmClientes.php // The content of the td is obtained during the execution of the code, but to make tests I put those values.
<div class="table-responsive" id="adicionados">
<table class="table" id="tabla">
<thead>
<tr>
<th>ID Articulo</th>
<th>Descripcion</th>
<th>Valor Venta</th>
<th>Cantidad</th>
<th>Subtotal</th>
</tr>
</thead>
<tbody>
<tr>
<td id="Sid">dw</td>
<td id="Sdescripcion">ads</td>
<td id="Svlrventa">ads</td>
<td id="Scantidad">da</td>
<td id="Ssubtotal">ad</td>
</tr>
</tbody>
The th refers to the fields of the tables and the td to what must be inserted respectively