Same as writing anything else into the page: print the variable's value at the appropriate spot in the URL, eg:
href="script.php?foo=<?php echo $bar?>"
So if $bar has the value 'wibble', the browser will be given the link
href="script.php?foo=wibble"
For safety's sake, that should probably be
href="script.php?foo=<?php echo urlencode($bar)?>"
in case $bar has characters in it that have special meanings in URLs.