Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2008-11-18, 12:38 AM
Junior Member
 
Join Date: Nov 2008
Location: Nairobi-Kenya
Posts: 1
DARZ is on a distinguished road
Send a message via Yahoo to DARZ
Smile 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">&nbsp;</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">&nbsp;</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....
Reply With Quote
  #2 (permalink)  
Old 2009-02-04, 08:50 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,165
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

You have two options, but using Dreamweaver is going to hurt if you dont understand the code behind it.

That said, either use one form (the easiest method) and use something like <fieldset> to break it up logically. I would go this route.

There is also a way to use JavaScript to handle this type of thing, but if you are using DW most likely that will be a total pain for you since it requires a pretty decent understanding of the DOM and how to gather the fields then submit.
__________________
My company's website: XM Tek
My Homepage/Blog
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Tags
form, inserting, multiple, records, tables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:27 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.