How to capture the code of a table generated via html?

1

I created a table with data by HTML and PHP, how do I generate a string from this table with this data so I can play in my DOMPDF load_html?

    
asked by anonymous 26.06.2017 / 19:49

1 answer

0

Assume that your table after while has been generated with the following structure:

<table>
    <tr>
        <td>
            bla
        </td>
        <td>
            ble
        </td>
    </tr>
    <tr>
        <td>
            bli
        </td>
        <td>
            blo
        </td>
    </tr>
</table>

When while is running, we can generate a variable with the rows of the table as follows

    while($row = $result->fetch_array()){
     $dados1 = $row["dados1"];
     $dados2 = $row["dados2"];
     $dados3 = $row["dados3"];
     $dados4 = $row["dados4"];
     $strLinhas = "<tr><td>".$dados1."</td><td>".$dados2."</td></tr><tr><td>".$dados3."</td><td>".$dados4."</td></tr>";
}

and after the while is executed concatenamos the result in the variable below

$strTabela = "<table>".$strLinhas."</table>";
    
27.06.2017 / 03:01