How to figure out which link has been clicked?

there are many links created dynamically in my html code and I want to redirect to another page using the one user clicks. but i get a wrong $_SESSION[‘recipeid’] each time I click one of the links.
here is my code in html:

<?php foreach($reciperesults as $recipe): ?>
    <div class="search1recipes">

            <div class="recipepicturediv">
                <?php $source = "Images/" . $recipe['picture']; ?>
                <img src="<?php echo $source;?>" alt="<?php echo $recipe['title'];?>" style="width:250px; height:200px;">
            <div class="recipeinfodiv">
                <p style="color: #660000;"> Country: <?php echo $country; ?>  &nbsp;  &nbsp; &nbsp; &nbsp;&nbsp; City: <?php echo $city; ?> </p>
                <p style="color:  #730099;"> Name: <?php echo $recipe['title']; ?> </p>
                <p style="color:  #000099;"> Preparation Time: <?php echo $recipe['preptime']; ?>  &nbsp;   &nbsp; &nbsp;  &nbsp;&nbsp;   Cooking Time: <?php echo $recipe['cookingtime']; ?> </p>
                <a href="detailrecipe.php" <?php $_SESSION['recipeid'] = $recipe['recipeid'];?> > See Recipe </a>
<?php endforeach; ?>