Thanks for your quick response.
I should have been clearer. I am using the query you suggested:
SELECT * FROM table WHERE letter = ?
But I am using it four times, once for each letter and thus one for each tab. I have a process file (process.php), and in that file I do the four database queries:
<?php
require_once('config.php');
// Connect to database //
$mysql = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// get data for A //
$A_data = $mysql->query("SELECT * FROM profiles WHERE letter = 'A'");
while($row = $A_data->fetch_object()) {
$A_results[] = $row;
}
// get data for B //
$B_data = $mysql->query("SELECT * FROM profiles WHERE letter='B'");
while($row = $B_data->fetch_object()) {
$B_results[] = $row;
}
... and the same for C and D.
In index.php, I require process.php and in each of the four tab-pane sections, I use a foreach loop. So a user clicks on tab A, and each "A" row is output as a bootstrap card as shown below.
<div class="container">
<div class="row">
<?php foreach ($A_results as $A_result) : ?>
<div class='col-md-4 col-sm-6 col-lg-3'>
<div class='card mt-5'>
<div class='card-body'>
<p><?php echo($A_result->name); ?></h4>
<p>Date: <?php echo ($A_result->date); ?></p>
<p>Address: <?php echo($A_result->address); ?></p>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
I do the same thing for B, C, and D. This works fine, but it seems hopelessly redundant. Now that you have seen my code, would you still suggest I go with the code you provided? Or is there something else I could try?
Thanks again for your help.