Im only getting the last value of my `foreach loop` and i gave it a unique id for all and i still get the last value

```
   <?php
        if (!empty($array)){
            foreach($array['users'] as $id){
                echo '<a href="#" id="btnClick" onClick="clickEvent();">
                        <div class="choices">
                            <dl>
                                <dt id="id'.$id['userID'].'">'.$id['userID'] .'</dt>
                                <dd id="name">'.$id['userName'].'</dd>    
                                <dd>'.$key.'</dd>
                            </dl>
                        </div>
                      </a>';
            }
        }
    ?>

```

and here is my `javascript` that i use to get the id so i can put it on url directly.

```
function clickEvent(){
        var foo = "<?php echo $id['userID'] ?>";
        var json = 'http://batz.web/Sandbox/details.php?userID=' + foo1;
        console.log(json);
        $.getJSON(json, function (results){
            document.getElementById("title").innerHTML = results.users[0].userID;
            document.getElementById("body").innerText = results.users[0].userAddress;
        });
    }

```