you need to join the tables like this
$sql = "SELECT answers., questions. FROM answers, questions WHERE answers.qno=questions.qno AND answers.name='" . $name . "'";
also modify the query checking to
$result = @($sql);
if (! $result) {
echo("SQL: " . $sql . "<br>Error: " . @mysql_error());
exit();
}
if (@mysql_num_rows($result) == 0) {
echo("No results returned");
exit();
}
// do stuff