GET_variable and javascript

I’m working with a while-loop that generates links
The while-loop generates this:

                   [left]             
   echo "<a href=\"javascript:PopupPic('".$bestandsnaam."')\">" 
echo "<img src='".$bestandsnaam."' border='0' height='60'>"  

[color=#000000][color=#cc0000]
[/color] [/color] [/left]

I would like to set a GET_variable, the variable is an id ,
but the id is generated together with the links in a while loop.
Because each link has a unique id I would like the unique id to be appended somewhere in it’s appropriate link.

when the link is clicked a piece of javascript code is executed:
[left]

<script language="Javascript"> function PopupPic(sPicURL) { window.open( "../../lib/php/popup.inc.php?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200"); } 

[/left]

I don’t want the id appended in this piece of code:
When the id is appended in this code, the value of the id is the last value that came out the while-loop and that’s not what I need.

Any clue?