You can do it like this:
first- make the queries and all of the required processing if needed in the <?php ?> part before <head>, make the varriables u use to stor the results as global Varriables
second- put the textfields as follows:
<input type="textfiled" name="any" value="<?php print $result_one ?>" >
this should initialize your textfield's value to the result you wanted