0

I am using heredoc statement for printing html, but how can we embed php code inside that html for example:

$results = $conn->query($sql);

$html = <<<html
<table class="table table-bordered table-striped table-hover">
    <thead>
        <tr>
            <th>ID</th>
            <th>Technician</th>
            <th>Project</th>
            <th>Region</th>
            <th>Date</th>
            <th>Type</th>
            <th>Notes</th>
        </tr>
    </thead>
    <tbody>
        <?php while($row = $results->fetch_assoc()): 
        <tr>
            <td>{$row['ID']}</td>
            <td>{$row['Technician']}</td>
            <td>{$row['Project']}</td>
            <td>{$row['Region']}</td>
            <td>{$row['Date']}</td>
            <td>{$row['Type']}</td>
            <td>{$row['Notes']}</td>
        </tr>
        <?php endwhile; ?>
    </tbody>
</table>
html;

How can we do something like that . . .

Osahady
  • 439
  • 7
  • 16

0 Answers0