I am taking list of data from my database using a loop. I loop one div but the values change depending on what I have in the database. I will want to get the id of the link that i click on from the individual divs. below is my html codes...
<?php
$query = $student->conn->prepare('SELECT * FROM groups');
$query->execute();
$result = $query -> fetchAll();
$count = 0;
foreach ($result as $row) {
    $count = $count + 1;
    $groupName = $row['GpName'];
    $groupAdmin = $row['GpAdmin'];
    $groupPurpose = $row['GpPurpose'];
    $output = "42";
    echo "<div class='animated flipInY col-sm-4'>
                <div class='tile-stats'>
                    <div class='icon'><i class='fa fa-tags'></i></div>
                    <div class='count'>$count</div>
                    <h3 id='groupName'>$groupName</h3>
                    <a id='$groupName' class='display' href='#'><p>Click here display group information.</p></a>
                </div>
            </div>";
}
?>
This is the jQuery code I use. it works in the console but it doesn't work on the page:
$('.display').on('click', function () {
    $(this).next();       
    var id = $(this).prev().val(); 
    alert(id);
});
 
     
    