Yes, using a URTL variable is the correct way to do this.
see the Database Getting started tutorial:
http://www.webassist.com/community/tutorials/view_tutorial.php?tid=104
is was written using standard MySQLi recordsets, but the concepts are the same using MySQLi.