in reply to Passing variables to a new script

Use a cgi parameter.
Script 1 does the massive sql query and gets all the initial data. Each record has a link to a script (could even be back to itself) with the added parameter as a get request. ( http://url/script.cgi?paramater_name=value )

Script 2 (or 1) then receives this param ( $q->param('name') ) and does a more refined SELECT and displays the full results.