Hi everyone.I'm quite new here but so far i like the expertise you guys have.I'm learning html,mysql and php basics all at the same time.My current task is creating a simple quiz form online.Each question has a unique id in the questions table on mysql.There is also an answers table and a widgets table.
A question can have multiple answers but each answer has only one question.A question can have only one widget type(a radio option,text area etc selected,for its answer mode.)
So far i have the tables with the primary and foreign keys created well in the database. eg.
answers and widgets tables both have a question_id field referencing the question_id(PK, auto increment) from the questions table.
The part which i find challenging is how to create a proper html form that will be able to insert a question to the questions table and at the same time insert the question_id in the answers and widgets tables?
I can't seem to get the sql query well and even the html form itself isn't quite right.I would really appreciate any help form you guys. Below is what i've tried so far :
<html>
<head>
<title> Create a new Survey </title>
<script type="text/javascript" src="script.js"></script>
</head>
<body style= "background: #D1D0CE">
Create a new Survey
<form action="insert.php" method="post">
Form Information
(Please enter your form details below.)
Form Name :
<input type="text" size="12" maxlength="40" name="formName"/>
Date :
<input type="date" size="12" maxlength="40" name="formDate"/>
Question Details
<input type="button" value="Add Question" önClick="addRow('questionTable')" />
<input type="button" value="Remove Question" önClick="deleteRow('questionTable')" />
<input type="checkbox" name="chk[]"/>
<label>Question : </label>
<input type="text" size = "16" maxlength= "50" name="description"/>
<label>Input Type :</label>
<select id="widgetType" name="widgetType" required="required">
<option>....</option>
<option>radio button</option>
<option>check box</option>
<option>Edit Text</option>
<option>Spinner</option>
<option>Rating bar</option>
</select>
Answer Details
<input type="button" value="Add Answer" önClick="addAnswer('answerTable')" />
<input type="button" value="Remove Answer" önClick="deleteAnswer('answerTable')" />
(Click to add more answer options.)
<input type="checkbox" name="chk[]"/>
<label>Answer : </label>
<input type="text" size="12" maxlength="40" name="answerText">
<label>Match to Question :</label>
<select id="QuestionNumber" name="question" required="required">
<option>....</option>
<option>Question 1</option>
<option>Question 2</option>
<option>Question 3</option>
<option>Question 4</option>
<option>Question 5</option>
<option>Question 6</option>
<option>Question 7</option>
<option>Question 8</option>
<option>Question 9</option>
<option>Question 10</option>
</select>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>