Problem with inserting records to multiple tables from one form
Please help me solve this....
I have a problem with inserting records to multiple tables using a single form. I am using the macromedia dreamweaver8 wizard to generate the forms. each form comes with a submit button.
all I need is to know how I can make these forms to submit their values to the respective talbles at ago using one submit button.
here is the code....
the database:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO educational_background (EduBgID, University_College, Degree_Diploma, Specialization, Date_From, Date_To) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['EduBgID'], "int"),
GetSQLValueString($_POST['University_College'], "text"),
GetSQLValueString($_POST['Degree_Diploma'], "text"),
GetSQLValueString($_POST['Specialization'], "text"),
GetSQLValueString($_POST['Date_From'], "date"),
GetSQLValueString($_POST['Date_To'], "date"));
mysql_select_db($database_conConsultant, $conConsultant);
$Result1 = mysql_query($insertSQL, $conConsultant) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf(*/&& "INSERT INTO skills (Consultant_SkillsID, Skill_One, Skill_Two, Skill_Three, Skill_Four, `Skill _Five`) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Consultant_SkillsID'], "int"),
GetSQLValueString($_POST['Skill_One'], "text"),
GetSQLValueString($_POST['Skill_Two'], "text"),
GetSQLValueString($_POST['Skill_Three'], "text"),
GetSQLValueString($_POST['Skill_Four'], "text"),
GetSQLValueString($_POST['Skill__Five'], "text"));
mysql_select_db($database_conConsultant, $conConsultant);
$Result1 = mysql_query($insertSQL, $conConsultant) or die(mysql_error());
}
these are the tables:
<table align="center" width="500" border="1" cellspacing="0" cellpadding="0">
<caption align="top">
Education Background
</caption>
<tr>
<th scope="col"> <table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">University/College:</td>
<td><input type="text" name="University_College" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Degree/Diploma:</td>
<td><input type="text" name="Degree_Diploma" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Specialization:</td>
<td><input type="text" name="Specialization" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Date From(yyyy-mm-dd):</td>
<td><input type="text" name="Date_From" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Date To(yyyy-mm-dd):</td>
<td><input type="text" name="Date_To" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<table align="center" width="500" border="1" cellspacing="0" cellpadding="0">
<caption align="top">
Countries of Experience
</caption>
<tr>
<th scope="col"> <table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country One:</td>
<td><input type="text" name="Country_One" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Two:</td>
<td><input type="text" name="Country_Two" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Three:</td>
<td><input type="text" name="Country_Three" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Four:</td>
<td><input type="text" name="Country_Four" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Five:</td>
<td><input type="text" name="Country_Five" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Six:</td>
<td><input type="text" name="Country_Six" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Seven:</td>
<td><input type="text" name="Country_Seven" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Country Eight:</td>
<td><input type="text" name="Country_Eight" value="" size="32" /></td>
</tr>
<!-- <tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr> -->
</table>
<input type="hidden" name="CountriesID" value="" />
<input type="hidden" name="MM_insert" value="form6" /> </th>
</tr>
</table>
please help me out....
|