如何使表格中显示的数据随选择框中选择的值而变化?

Based on the user that is chosen within the combo box, I want the table that is displaying user data from the database to only show the data corresponding to the user selected in the combo box.

I mainly tried using an array to store values but I couldn't get that working.

Combo Box that displays the name to pick

    <select>
        <?php
        $res = mysqli_query($db, "SELECT * FROM shifts");
        while ($row = mysqli_fetch_array($res))
        {
            ?>
            <option><?php echo $row ["name"]; ?></option>
            <?php
        }
        ?>
        <button class="btn-primary rounded">Find</button>
    </select>
</form>

Table that shows the data from the database.

<table class="table table-hover">
    <thead class="thead-dark"></thead>
    <tr>
        <th scope="col">Shift ID</th>
        <th scope="col">Name</th>
        <th scope="col">Origin</th>
        <th scope="col">Destination</th>
        <th scope="col">Date</th>
    </tr>
    </thead>
    <?php
    global $result;
    //Fetch Data form database
    if($result->num_rows > 0){
        while($row = $result->fetch_assoc()){
            ?>
         <tbody>
            <tr>
                <td><?php echo $row['shift_id']; ?></td>
                <td><?php echo $row['name']; ?></td>
                <td><?php echo $row['origin']; ?></td>
                <td><?php echo $row['destination']; ?></td>
                <td><?php echo $row['date']; ?></td>
            </tr>
         </tbody>
</table>

I'm wondering if by using the form and doing a function that on pressing the Find button it looks up the user and displays only it's data. Thanks

Check my code here, there are some thing you must add, like a WHERE statement to your query, when fetching data to only show results with the selected name in the form

<!-- Create a form with a select for all the names -->
<form method="POST" action="">
    <select name="name">
        <?php
        $res = mysqli_query($db, "SELECT * FROM shifts");
        while ($row = mysqli_fetch_array($res))
        {
            ?>
            <option><?php echo $row ["name"]; ?></option>
            <?php
        }
        ?>
        <button class="btn-primary rounded" name="find_info">Find</button>
    </select>
</form>

<?php
if(isset($_POST['find_info'])){ //If find button is pressed, show this:
?>
    <table class="table table-hover">
        <thead class="thead-dark"></thead>
        <tr>
            <th scope="col">Shift ID</th>
            <th scope="col">Name</th>
            <th scope="col">Origin</th>
            <th scope="col">Destination</th>
            <th scope="col">Date</th>
        </tr>
        </thead>
        <?php
        global $result;
        $nameSelected = strip_tags(mysqli_real_escape_string(htmlspecialchars($_POST['name'])));
        // Use WHERE in your mysqli query to fetch data where name in database is equal to $nameSelected
        if($result->num_rows > 0){
            while($row = $result->fetch_assoc()){
                ?>
             <tbody>
                <tr>
                    <td><?php echo $row['shift_id']; ?></td>
                    <td><?php echo $row['name']; ?></td>
                    <td><?php echo $row['origin']; ?></td>
                    <td><?php echo $row['destination']; ?></td>
                    <td><?php echo $row['date']; ?></td>
                </tr>
             </tbody>
    </table>
<?php
}
?>