Q:

set active class for dynamically generated links in php

In my application there is a page where I generate dynamic links based on the data from mysql DB. My task is to set a class="active" for the selected link. If the links where static I can give active class using page name like this. But what to do in my case? Is there any way to get this done?
Here is my code:
                <div class="select-region clearfix">
                <input type="hidden" id="rgnId" name="rgnId">
                <input type="hidden" id="hltypId" name="hltypId">
                <ul class="nav">
                    <li>Select your region</li>
                     <li value="0"><a class="active" id="show_0" onClick="UAEHolydayDetails(0)">All<span class="badge"><?php echo $uaedetailscount?></span></a></li> 
                    <?php
                     $i=0;
                      while($rowrgn = $rsltrgn->fetchAssoc())
                      {
                      ?>
                        <li><a  id="show_<?php echo $rowrgn['rgnId']; ?>" onClick="UAEHolydayDetails(<?php echo $rowrgn['rgnId']; ?>)"><?php echo $rowrgn['rgnName']; ?><span class="badge">
                            <?php echo $rowrgn['regioncount'];?></span></a></li>  
                  <?php } ?>
                </ul>
            </div>

can anyone please help me
Edit 1
when I click any of these dynamic links it passes an id to the same page through js and the page will be filled with data from DB based on this paseed id like this:
onClick="UAEHolydayDetails(<?php echo $rowrgn['rgnId']; ?>)"
js:
<script>
function HolytypeDetails(id){
$('#hltypId').val(id);
window.location='uae-holidays.php?hltypId='+id;
}
</script>

in script the page in window.location is the page where the links are generated itself

A:

Of course. It's the same thing. You need to know your active item id and based on this information just chose the item you want.

<?php
  $activePageId = 5;

  $i=0;
  while($rowrgn = $rsltrgn->fetchAssoc())
  {
?>
  <li <?php if($rowrgn['rgnId'] === $activePageId){ ?>class="active"<?php } ?>><a id="show_<?php echo $rowrgn['rgnId']; ?>" onClick="UAEHolydayDetails(<?php echo $rowrgn['rgnId']; ?>)"><?php echo $rowrgn['rgnName']; ?><span class="badge">
  <?php echo $rowrgn['regioncount'];?></span></a></li>  
<?php } ?>

