Flex app for quizzing
You could combine your two SQL queries so you don't have to hit the database twice.

The new SQL statement would be something like this:

SELECT
    q.id, q.question_number, q.chapter_id, q.section_id, 
    q.question_txt, q.answers, q.feedbacks, q.correct_answer, 
    q.question_type, q.module, q.shuffle_answer,
    q.tags, COALESCE(t.id, 0) As tagged
FROM questions q
     LEFT JOIN tagged t ON q.question_number = t.question_number AND t.user_id = ?
WHERE q.question_number=?


The COALESCE function would return the id from the tagged table if one exists, otherwise it returns 0.  This eliminates the need for your final if/else statement and gives you a direct mapping for $row->tagged.

You should also release all result sets and close all connections before issuing a return statement.  Any code after a return statement will not be executed.