what i think you're talking about is you have a set of queries such as
$query1 = "SELECT foo FROM bar WHERE clown='bozo'";
and what you want to do is this
<a href="do_my_query_stuff.php?query=$query1">hit me</a>
and it's barfing like a frat pledge... because the spaces and equals signs in your $query1 string ar causing problems. To solve this you should use our pal urlencode(), which basically turns spaces anything that's not a number, letter or underscore into the url code so it can be passed via GET. so we would try:
echo "<a href=\"do_yatta_yatta.php?query=" . urlencode($query1) . "\">ack</a>";
now, on your receiving page, this needs to be translated back with urldecode(). so you would call:
$result = pg_exec($db, urldecode($query1));
or whatever the mysql version of said call would be....
if that's not what you're looking for then, oops.