change content when clicking from list [closed]

I would like to consult my webpage function.
Alert Viewing System Web Page

First, using mysqli fetch_assoc(), I’m able to display a list of Alert IDs that is clickable. I want to display the content of a specific Alert (Id, time, picture, etc. saved in MySQL database) on the right side of the webpage every time I click on the ID on the left.

I was thinking of adding onclick function to the clickable ID to do the job, is it possible, or anyone has another idea of how to complete this process? Thanks!

Below is my code:

<?php
require_once('config.php');
session_start();

$uname = $_SESSION['uname'];
$sql = "SELECT * FROM users
 WHERE username = '$uname'";
$result = mysqli_query($link, $sql);
$data = $result->fetch_all(MYSQLI_ASSOC);

if (!isset($_SESSION['uname'])){
    echo "<script type='text/javascript'>alert('請先登入');
    window.location='login.php';</script>";}

    $sql2 = " SELECT * FROM coba WHERE branch = 'a'";
    $sql3 = " SELECT * FROM coba WHERE branch = 'b'";
    $sql4 = " SELECT * FROM coba WHERE branch = 'c'";
    $result2 = mysqli_query($link, $sql2);
    $result3 = mysqli_query($link, $sql3);
    $result4 = mysqli_query($link, $sql4);
?>
<!DOCTYPE html>
<html>
<head>
    <title>工地警報查看系統</title>
    <link rel="stylesheet" type="text/css" href="homepage.css">
</head>
<body>
    <div class = "header">
        <div class = "branch-name">
            <?php
                    if(str_contains($uname, 'KS1')){
                         echo"「高雄鳳山」 工地警報查看系統";
                    }
                    elseif(str_contains($uname, 'TC1')){
                         echo"「台中會展中心」 工地警報查看系統";
                    }
                    elseif(str_contains($uname, 'TC2')){
                        echo"「台中火力發電厰」 工地警報查看系統";
                   }
            ?>
        </div>
    </div>
    <div class = "background-color">
        <div class = "box-left">
        <div class = "text">ID</div>
        <?php
        if(str_contains($uname, 'KS1')){
                {
                    $count2 = mysqli_num_rows($result2);
                    if($count2 == "0")
                    {
                        $output2 = '<h2>無資料</h2>';
                    }
                    else
                    {
                        while($row2 = $result2->fetch_assoc())
                        {
                        ?>
                        <div class = "table-border">
                        <table id = "table-border"> 
                        <a href = ""><?php echo $row2['id'];?></div></br>
                        </table>
                        </div>
                        <?php
                        }
                    }
                }
            }
            //else if click on button b
            elseif(str_contains($uname, 'TC1'))
                {
                    $count3 = mysqli_num_rows($result3);
                    if($count3 == "0")
                    {
                        $output3 = '<h2>無資料</h2>';
                    }
                    else
                    {
                        while($row3 = $result3->fetch_assoc()){
                        ?>
                        <div class = "table-border">
                        <table id = "table-border"> 
                        <a href = ""><?php echo $row3['id'];?></div></br>
                        </table>
                        </div>
                        <?php
                        }
                    }
                }
            //else if click on button c
            elseif(str_contains($uname, 'TC2'))
                {
                    $count4 = mysqli_num_rows($result4);
                    if($count4 == "0"){
                        $output4 = '<h2>無資料</h2>';
                    }
                    else
                    {
                        while($row4 = $result4->fetch_assoc()){
                        ?>
                        <div class = "table-border">
                        <table id = "table-border"> 
                        <a href = ""><?php echo $row4['id'];?></div></br>
                        </table>
                        </div>
                        <?php
                        }
                    }
                }
            ?>
            <div class = "logout"><a href = "logout.php">登出</a></div>
        </div>
        <div class = "box-right">
        <a id = "id">
        <?php           
        $sql1 = "SELECT * FROM coba WHERE id = id";
        $result1 = mysqli_query($link, $sql1);
        $data1 = $result1->fetch_all(MYSQLI_ASSOC);
            foreach ($data1 as $row1)
            {
                echo  "<h3>" . "ID = ". $row1['id'] . "</h3>";
                echo  "<h3>" . "警 報 時 間 = ". $row1['time'] . "</h3>";
                echo  "<h3>" . "警 報 内 容 = ". $row1['rule'] . "</h3>";
        ?>
                <div class = "image">
                    <img src="<?php echo $row1['picture']; ?>" width = "300" height = "300" />
                </div>
        <?php
            }
        ?>
        </a>
        </div>
    </div>
</body>
</html>