I'm trying to use an html table with tabs and fill each tab with php content. Here's my code so far: ...
<html>
<body>
<!--div class="tab"
<button class="tablinks" onclick="openCity(event, 'October')">October</button>
<button class="tablinks" onclick="openCity(event, 'November')">November</button>
<button class="tablinks" onclick="openCity(event, 'December')">December</button>
/div
<div id="October" class="tabcontent">
<? php
$filepath = '\data\2020_10_data';
if (file_exists($filepath)) {
$file = fopen($filepath, 'r');
echo "<table>
<table border=1>
<tr>
<th>Date</th>
<th>Time</th>
<th>Who </th>
<th>Action</th>
<th>Rule</th>
<th>Attribute</th>
</tr>";
while (!feof($file)) {
$line = fgets($file);
$first_char = $line[0];
if ($first_char != '*' && $first_char != '^' && trim($line) != '') {
if (strstr($line, ',')) {
$split = explode(',', $line);
echo "<tr>";
foreach($split as $line) {
echo "<td>".$line."</td>";
}
echo "</tr>";
} else {
echo "<tr><td>".$line."</td></tr>";
}
}
}
echo "</table>";
} else {
echo "the file does not exist";
}
?>
</div>
</body>
</html>
...
The tabs and table headers within the tab are displayed properly. But instead of filling the table with the content of the file the source code is written on the the page. I tested thr php part alone and it worked fine and displayed a table with the file content. I'm probably just missing something small but I can't find it. Any ideas?