You have to know which radio will be selected by holding answer in some variable, for exmaple $givenanswer. Well if $givenanswer is empty - no problem, nothing will be selected
<input type="radio" name="<?php echo $row['qid'];?>" value="<?php echo $row['ans1'];?>" <?php if ($givenanswer==$row['ans1']){ echo 'checked="checked" ';}?> />