I want to present data from an SQL database on an HTML page. A portion of the code I have is below
<?php
include 'connection.php';
$conn = OpenCon();
include 'vulntable.php';
TableInsert()
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 50;
$offset = ($pageno-1) * $no_of_records_per_page;
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
die();
}
$total_pages_sql = "SELECT COUNT(*) FROM `vulnerability`";
$result = mysqli_query($conn,$total_pages_sql);
$total_rows = mysqli_fetch_array($result)[0];
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql = "SELECT * FROM `vulnerability` LIMIT $offset, $no_of_records_per_page";
$res_data = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($res_data)){
echo "<div class='table-responsive'><table id='myTable' class='table table-striped table-bordered'>
<thead><tr><th>Vul_name</th>
<th>Website</th>
<th>Vendor</th>
<th>ESB</th>
<th>CVE</th>
<th>Date</th>
</tr></thead><tbody>";
echo "<tr>
<td>" . $row['Vul_name']."</td>
<td>" . $row['Website']."</td>
<td>" . $row['Vendor']."</td>
<td>" . $row['ESB']."</td>
<td>" . $row['CVE']."</td>
<td>" . $row['date_reported']."</td>
</tr>";
echo "</tbody></table></div>";
}
mysqli_close($conn);
?>
<ul class="pagination">
When getting displayed through a browser though it comes shows as shown here:
My assumptions as to why the issue is occurring is due to the greater than ">" character "exiting" the <?PHP portion of the code and therefore the lines aren't able to be read as PHP. I have attempted to put more 'echo' in every line however that did not work.