I have a database structure similar to the following schema that holds survey information for different types of surveys:

Questionnaires for Marketing Surveys

I've created the surveys and the question that should appear on the survey from within the database. Currently I have 3 surveys each with different questions. How would I go about querying the database to create a html form with text boxes and radio buttons on the fly based on the what questions should appear on the survey form?

The hardway is to custom build the html forms with fields that map to the questions in the database. However this can become tedious when everytime a new survey form needs creating with different questions.

Basically am looking for some code example that will help me get started off to dynamically generate a html survey form based on the information stored in the database. I'm sure somebody must have done something similar before.

Any help will be much appreciated.