PHP & Hosted Applications by Ahmad Abualsamid Listing One
Please enter the survey's name
Please enter a short description
Please enter the number of questions in the survey
Listing Two
"); for ($i=0;$i<$survey_questions;$i++) { $j = $i+1; printf ("Select Question Type for Question $j

"); printf (""); printf ("
If Radio Button or Check Box:

"); printf ("
Number of Choices "); printf ("
"); printf ("
"); printf ("Provide an Other option
"); printf ("
"); } ?>
Listing Three
"); $choice_counter=0; for ($i=0;$i<$survey_questions;$i++) { echo "
"; $j=$i+1; echo "Question #$j is: "; echo "\n"; echo "\n"; printf ("\n"); switch ($questions_type[$i]) { case 0: echo "

"; break; case 1: printf("
"); for ($counter=0;$counter<$choices[$i];$counter++) { printf ("Choice #$counter: \n"); if ($counter && ($counter % 2 == 0)) echo "
\n"; $choice_counter++; } break; case 2: printf("
"); for ($counter=0;$counter<$choices[$i];$counter++) { printf ("Choice #$counter: \n"); if ($counter && ($counter % 2 == 0)) echo "
\n"; $choice_counter++; } break; default: echo $questions_type[$i]; break; } echo "


"; } ?>
Listing Four $stmt = "insert into surveys.survey (name,lastupdate,DateCreated,OwnerID, "; $stmt = $stmt . "Description,isClosed) values ('$survey_name',now(),now(),0"; $stmt = $stmt . ",'$survey_description',0)"; if (!(mysql_query($stmt)) { { printf ("Failed in Creating the Survey Entry..."); exit(); } Listing Five <% Dim myObject Set myObject = Server.CreateObject("MyProject.MyClass") Dim myString myString = myObject.GetDataBaseName Response.Write "The Database name is " & myString %> Listing Six GetDataBaseName(); echo "The Database name is $myString"; ?> Example 1: Create table survey (ID not int not null auto_increment, name varchar(255), LastUpdate date, DateCreated Date, OwnerID number, Description varchar(255), IsClosed smallint, primary key(ID)); Example 2: Create Table Questions (ID int not null auto_increment, SurveyID int not null, QuestionType smallint, QuestionText varchar(255), NumberOfChoices smallint, isRequired smallint, primary key (ID), index (SurveyID)); Example 3: Create Table Choices (ID int not null auto_increment, QuestionID int not null, Text varchar(255), primary key (ID), index (QuestionID)); Example 4: Create Table Answers (SurveyID number, QuestionID number, ChoiceSelected smallint, AnswerText varchar(255)); 1