Generate Forms for MySQL Insert

A

Anonymous

Guest
I have two tables:
`parent`
parentid
parentname

`child`
childid
parentid
childname
childage

This is my initial html
Code:
<form> 
parent name: <input type="text" name="parentname"><br> 
children: <input type="text" name="child1">  Age:<input type="text"
name="ageforchild1"> <a href="questionhere.link">Add Child Field</a> 
</form>
I have two questions here. One is what is the code in adding a childfield link link so that when I click that, another forms will be generated or the code above will become like this after I click the add child filed
Code:
<form> 
parent name: <input type="text" name="parentname"><br> 
children: <input type="text" name="child1">  Age:<input type="text" 
name="ageforchild1"><br> 
children 2: <input type="text" name="child2">  Age:<input type="text" 
name="ageforchild2"> <a href="questionhere.link">Add Child Field</a> 
</form>
Another question is how to insert this into database since this will insert into the `parent` table and multiple row for the `child` table.

Thank you.[/code]
 
Code:
function show_child_insert_form()
{
   //html
}


function show_child_insert_form()
{
   //html
}


if (!empty($_POST['parentname'])) {
   // value of parent present
   show_child_insert_form();
} else {
   show_parent_insert_form();
}
 
Back
Top