Basically, here is what I have:
- 2 Main Tabs;
- 1 Main Tabs has 4 SubTabs;
- Each Tab needs to load code upon selection.
Here is the Nav code:
<div class="container-fluid mt-3">
<ul class="nav nav-pills justify-content-center" id="tab-city" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="city-dr" data-toggle="tab" href="#droh" role="tab" aria-controls="droh" aria-selected="true">Drohobych</a>
</li>
</ul>
<div class="tab-content" id="city-content">
<div class="tab-pane show active" id="droh" role="tabpanel" aria-labelledby="city-dr">
<ul class="nav nav-pills justify-content-center" id="table-content" role="tablist">
<li class="nav-item mt-2">
<a class="nav-link active" id="droh-repair" data-toggle="tab" href="#droh-repairs" role="tab" aria-controls="droh-repairs" aria-selected="true">Repair</a>
</li>
<li class="nav-item">
<a class="nav-link active" id="table-dr-fttb-pull-in" role="tab">FTTB Pull In</a>
</li>
</ul>
<div class="tab-content" id="table-content">
<div class="tab-pane show active" id="droh-repairs" role="tabpanel" aria-labelledby="city-dr">
<?php
include(__DIR__ . '/tables/dr/table_dr_repair.php');
?>
</div>
</div>
</div>
</div>
</div>
This is the code that I am trying to include:
<?php
require_once(__DIR__ . '/../../headers/navbar.php');
require_once(__DIR__ . '/../../../db/db_handler.php');
require_once(__DIR__ . '/../../../util/constants.php');
require_once(__DIR__ . '/../../../util/util.php');
?>
<table class="table table-bordered table-hover table-sm">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Street</th>
<th scope="col">Phone</th>
<th scope="col">Date</th>
<th scope="col">Price</th>
<th scope="col">Comment</th>
<th scope="col">Operator</th>
</tr>
</thead>
<?php
$stmt = $connection->prepare("SELECT * FROM `" . Tables::$table_dr_fttb_pull_in . "` ORDER BY `date` DESC");
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_array()) {
print_task_details_as_table_row($row);
}
?>
</table>
The problem is - nothing happens when the Tab is selected. What I could do - simply get all the code from the file and insert it into HTML page. However, I am not really fan of that solution since doing that for 7 more subtabs will result into one gigantic page with lots of repetitive code.
That's why I would rather do it this way. How do I load the content when the tab is pressed? Perhaps there is even a better way to handle this, so please help me figure this out.