2014-01-26 51 views
0

正如你可以看到我正在做一個記分板程序我有多個條目,我需要保存到數據庫......但我的問題是'frm1'只保存在數據庫中我輸入的其他9項不保存?順便說一句,我只是一個新手程序員我的代碼是醜陋的抱歉。不能插入多個數據需要救援

的html代碼:

<form action="interview.php" method="post"> 
<font color="#000000"> 
<center> 
<table border="1" width="970" height="" bgcolor="#FFFFFF"> 
    <br /> 
    <center> 
    <table border="1" width="910" height="" cellpadding="0" cellspacing="0" align="center"> 

     <tr height="8"> 
      <form name="frm1" id="frm1" > 
      <td width="369"><input name="name1" type="text" value="" required size="41" id="query1" onblur="getvalues1()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA1" value="1" onClick="optTotal1()" />1 
      <input type="radio" name="optA1" value="2" onClick="optTotal1()" />2 
      <input type="radio" name="optA1" value="3" onClick="optTotal1()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB1" value="1" onClick="optTotal1()" />1 
      <input type="radio" name="optB1" value="2" onClick="optTotal1()" />2 
      <input type="radio" name="optB1" value="3" onClick="optTotal1()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC1" value="1" onClick="optTotal1()" />1 
      <input type="radio" name="optC1" value="2" onClick="optTotal1()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD1" value="1" onClick="optTotal1()" />1 
      <input type="radio" name="optD1" value="2" onClick="optTotal1()" />2 
      </td> 
      <td width="53"><input type="text" name="total1" onKeyUp="optTotal1()" readonly size="3" /></td> 
      <td width="87"><input name="remarks1" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
     <form name="frm2" id="frm2" > 
      <td width="369"><input name="name2" type="text" value="" required size="41" id="query2" onblur="getvalues2()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA2" value="1" onClick="optTotal2()" />1 
      <input type="radio" name="optA2" value="2" onClick="optTotal2()" />2 
      <input type="radio" name="optA2" value="3" onClick="optTotal2()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB2" value="1" onClick="optTotal2()" />1 
      <input type="radio" name="optB2" value="2" onClick="optTotal2()" />2 
      <input type="radio" name="optB2" value="3" onClick="optTotal2()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC2" value="1" onClick="optTotal2()" />1 
      <input type="radio" name="optC2" value="2" onClick="optTotal2()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD2" value="1" onClick="optTotal2()" />1 
      <input type="radio" name="optD2" value="2" onClick="optTotal2()" />2 
      </td> 
      <td width="53"><input type="text" name="total2" id="total2" onKeyUp="optTotal2()" readonly size="3" /></td> 
      <td width="87"><input name="remarks2" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
      <form name="frm3" id="frm3" > 
      <td width="369"><input name="name3" type="text" value="" required size="41" id="query3" onblur="getvalues3()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA3" value="1" onClick="optTotal3()" />1 
      <input type="radio" name="optA3" value="2" onClick="optTotal3()" />2 
      <input type="radio" name="optA3" value="3" onClick="optTotal3()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB3" value="1" onClick="optTotal3()" />1 
      <input type="radio" name="optB3" value="2" onClick="optTotal3()" />2 
      <input type="radio" name="optB3" value="3" onClick="optTotal3()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC3" value="1" onClick="optTotal3()" />1 
      <input type="radio" name="optC3" value="2" onClick="optTotal3()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD3" value="1" onClick="optTotal3()" />1 
      <input type="radio" name="optD3" value="2" onClick="optTotal3()" />2 
      </td> 
      <td width="53"><input type="text" name="total3" onKeyUp="optTotal3()" readonly size="3" /></td> 
      <td width="87"><input name="remarks3" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
      <form name="frm4" id="frm4" > 
      <td width="369"><input name="name4" type="text" value="" required size="41" id="query4" onblur="getvalues4()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA4" value="1" onClick="optTotal4()" />1 
      <input type="radio" name="optA4" value="2" onClick="optTotal4()" />2 
      <input type="radio" name="optA4" value="3" onClick="optTotal4()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB4" value="1" onClick="optTotal4()" />1 
      <input type="radio" name="optB4" value="2" onClick="optTotal4()" />2 
      <input type="radio" name="optB4" value="3" onClick="optTotal4()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC4" value="1" onClick="optTotal4()" />1 
      <input type="radio" name="optC4" value="2" onClick="optTotal4()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD4" value="1" onClick="optTotal4()" />1 
      <input type="radio" name="optD4" value="2" onClick="optTotal4()" />2 
      </td> 
      <td width="53"><input type="text" name="total4" onKeyUp="optTotal4()" readonly size="3" /></td> 
      <td width="87"><input name="remarks4" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
      <form name="frm5" id="frm5" > 
      <td width="369"><input name="name5" type="text" value="" required size="41" id="query5" onblur="getvalues5()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA5" value="1" onClick="optTotal5()" />1 
      <input type="radio" name="optA5" value="2" onClick="optTotal5()" />2 
      <input type="radio" name="optA5" value="3" onClick="optTotal5()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB5" value="1" onClick="optTotal5()" />1 
      <input type="radio" name="optB5" value="2" onClick="optTotal5()" />2 
      <input type="radio" name="optB5" value="3" onClick="optTotal5()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC5" value="1" onClick="optTotal5()" />1 
      <input type="radio" name="optC5" value="2" onClick="optTotal5()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD5" value="1" onClick="optTotal5()" />1 
      <input type="radio" name="optD5" value="2" onClick="optTotal5()" />2 
      </td> 
      <td width="53"><input type="text" name="total5" onKeyUp="optTotal5()" readonly size="3" /></td> 
      <td width="87"><input name="remarks5" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
      <form name="frm6" id="frm6" > 
      <td width="369"><input name="name6" type="text" value="" required size="41" id="query6" onblur="getvalues6()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA6" value="1" onClick="optTotal6()" />1 
      <input type="radio" name="optA6" value="2" onClick="optTotal6()" />2 
      <input type="radio" name="optA6" value="3" onClick="optTotal6()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB6" value="1" onClick="optTotal6()" />1 
      <input type="radio" name="optB6" value="2" onClick="optTotal6()" />2 
      <input type="radio" name="optB6" value="3" onClick="optTotal6()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC6" value="1" onClick="optTotal6()" />1 
      <input type="radio" name="optC6" value="2" onClick="optTotal6()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD6" value="1" onClick="optTotal6()" />1 
      <input type="radio" name="optD6" value="2" onClick="optTotal6()" />2 
      </td> 
      <td width="53"><input type="text" name="total6" onKeyUp="optTotal6()" readonly size="3" /></td> 
      <td width="87"><input name="remarks6" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
      <form name="frm7" id="frm7" > 
      <td width="369"><input name="name7" type="text" value="" required size="41" id="query7" onblur="getvalues7()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA7" value="1" onClick="optTotal7()" />1 
      <input type="radio" name="optA7" value="2" onClick="optTotal7()" />2 
      <input type="radio" name="optA7" value="3" onClick="optTotal7()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB7" value="1" onClick="optTotal7()" />1 
      <input type="radio" name="optB7" value="2" onClick="optTotal7()" />2 
      <input type="radio" name="optB7" value="3" onClick="optTotal7()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC7" value="1" onClick="optTotal7()" />1 
      <input type="radio" name="optC7" value="2" onClick="optTotal7()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD7" value="1" onClick="optTotal7()" />1 
      <input type="radio" name="optD7" value="2" onClick="optTotal7()" />2 
      </td> 
      <td width="53"><input type="text" name="total7" onKeyUp="optTotal7()" readonly size="3" /></td> 
      <td width="87"><input name="remarks7" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
     <form name="frm8" id="frm8" > 
      <td width="369"><input name="name8" type="text" value="" required size="41" id="query8" onblur="getvalues8()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA8" value="1" onClick="optTotal8()" />1 
      <input type="radio" name="optA8" value="2" onClick="optTotal8()" />2 
      <input type="radio" name="optA8" value="3" onClick="optTotal8()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB8" value="1" onClick="optTotal8()" />1 
      <input type="radio" name="optB8" value="2" onClick="optTotal8()" />2 
      <input type="radio" name="optB8" value="3" onClick="optTotal8()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC8" value="1" onClick="optTotal8()" />1 
      <input type="radio" name="optC8" value="2" onClick="optTotal8()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD8" value="1" onClick="optTotal8()" />1 
      <input type="radio" name="optD8" value="2" onClick="optTotal8()" />2 
      </td> 
      <td width="53"><input type="text" name="total8" onKeyUp="optTotal8()" readonly size="3" /></td> 
      <td width="87"><input name="remarks8" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
     <form name="frm9" id="frm9" > 
      <td width="369"><input name="name9" type="text" value="" required size="41" id="query9" onblur="getvalues9()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA9" value="1" onClick="optTotal9()" />1 
      <input type="radio" name="optA9" value="2" onClick="optTotal9()" />2 
      <input type="radio" name="optA9" value="3" onClick="optTotal9()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB9" value="1" onClick="optTotal9()" />1 
      <input type="radio" name="optB9" value="2" onClick="optTotal9()" />2 
      <input type="radio" name="optB9" value="3" onClick="optTotal9()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC9" value="1" onClick="optTotal9()" />1 
      <input type="radio" name="optC9" value="2" onClick="optTotal9()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD9" value="1" onClick="optTotal9()" />1 
      <input type="radio" name="optD9" value="2" onClick="optTotal9()" />2 
      </td> 
      <td width="53"><input type="text" name="total9" onKeyUp="optTotal9()" readonly size="3" /></td> 
      <td width="87"><input name="remarks9" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

     <tr height="8"> 
      <form name="frm10" id="frm10" > 
      <td width="369"><input name="name10" type="text" value="" required size="41" id="query10" onblur="getvalues10()" /></td> 
      <td width="113"> 
      <input type="radio" name="optA10" value="1" onClick="optTotal10()" />1 
      <input type="radio" name="optA10" value="2" onClick="optTotal10()" />2 
      <input type="radio" name="optA10" value="3" onClick="optTotal10()" />3 
      </td> 
      <td width="109"> 
      <input type="radio" name="optB10" value="1" onClick="optTotal10()" />1 
      <input type="radio" name="optB10" value="2" onClick="optTotal10()" />2 
      <input type="radio" name="optB10" value="3" onClick="optTotal10()" />3 
      </td> 
      <td width="79"> 
      <input type="radio" name="optC10" value="1" onClick="optTotal10()" />1 
      <input type="radio" name="optC10" value="2" onClick="optTotal10()" />2 
      </td> 
      <td width="84"> 
      <input type="radio" name="optD10" value="1" onClick="optTotal10()" />1 
      <input type="radio" name="optD10" value="2" onClick="optTotal10()" />2 
      </td> 
      <td width="53"><input type="text" name="total10" onKeyUp="optTotal10()" readonly size="3" /></td> 
      <td width="87"><input name="remarks10" type="text" value="" required size="8" readonly /></td> 
      </form> 
     </tr> 

      </table></center> 
      <center> 
    <br /> 
     _______________________________<br /> 
       Signature of Rater 
     <br></center> 
     <br> 
<!--hidden inputs for repcode and username session starts--> 

<input type="hidden" name="username" id="username" value="<?php echo $_SESSION['username']; ?> " /> 
<input type="hidden" name="repcode" id="repcode" value="<?php echo $_SESSION['repcode']; ?> " /> 

<!--hidden inputs for repcode and username session starts--> 
<!--hidden inputs for aic and batchcode starts--> 
<!--1--> 
<input type="hidden" name="aic1" id="aic1"/> 
<input type="hidden" name="batchcode1" id="batchcode1" /> 
<!--2--> 
<input type="hidden" name="aic2" id="aic2"/> 
<input type="hidden" name="batchcode2" id="batchcode2" /> 
<!--3--> 
<input type="hidden" name="aic3" id="aic3"/> 
<input type="hidden" name="batchcode3" id="batchcode3" /> 
<!--4--> 
<input type="hidden" name="aic4" id="aic4"/> 
<input type="hidden" name="batchcode4" id="batchcode4" /> 
<!--5--> 
<input type="hidden" name="aic5" id="aic5"/> 
<input type="hidden" name="batchcode5" id="batchcode5" /> 
<!--6--> 
<input type="hidden" name="aic6" id="aic6"/> 
<input type="hidden" name="batchcode6" id="batchcode6" /> 
<!--7--> 
<input type="hidden" name="aic7" id="aic7"/> 
<input type="hidden" name="batchcode7" id="batchcode7" /> 
<!--8--> 
<input type="hidden" name="aic8" id="aic8"/> 
<input type="hidden" name="batchcode8" id="batchcode8" /> 
<!--9--> 
<input type="hidden" name="aic9" id="aic9"/> 
<input type="hidden" name="batchcode9" id="batchcode9" /> 
<!--10--> 
<input type="hidden" name="aic10" id="aic10"/> 
<input type="hidden" name="batchcode10" id="batchcode10" /> 
<!--hidden inputs for aic and batchcode ends-->  

<input type="submit" style="width:964px;height:30px" value="CLICK ME TO SAVE" name="save" id="press" /> 

     </center> 
     </td> 
     </tr> 
</table> 
</font> 
</form> 

PHP代碼:

<?php 

if(isset($_POST['save'])) 
{ 
include('connection.php'); 
//opt1 
$opt1aic = array_key_exists('aic1', $_POST) ? $_POST['aic1'] : null; 
$opt1batchcode = array_key_exists('batchcode1', $_POST) ? $_POST['batchcode1'] : null; 
$opt1name = array_key_exists('name1', $_POST) ? $_POST['name1'] : null; 
$opt1score1 = array_key_exists('optA1', $_POST) ? $_POST['optA1'] : null; 
$opt1score2 = array_key_exists('optB1', $_POST) ? $_POST['optB1'] : null; 
$opt1score3 = array_key_exists('optC1', $_POST) ? $_POST['optC1'] : null; 
$opt1score4 = array_key_exists('optD1', $_POST) ? $_POST['optD1'] : null; 
$opt1total = ($opt1score1 + $opt1score2 + $opt1score3 + $opt1score4); 
//opt2 
$opt2aic = array_key_exists('aic2', $_POST) ? $_POST['aic2'] : null; 
$opt2batchcode = array_key_exists('batchcode2', $_POST) ? $_POST['batchcode2'] : null; 
$opt2name = array_key_exists('name2', $_POST) ? $_POST['name2'] : null; 
$opt2score1 = array_key_exists('optA2', $_POST) ? $_POST['optA2'] : null; 
$opt2score2 = array_key_exists('optB2', $_POST) ? $_POST['optB2'] : null; 
$opt2score3 = array_key_exists('optC2', $_POST) ? $_POST['optC2'] : null; 
$opt2score4 = array_key_exists('optD2', $_POST) ? $_POST['optD2'] : null; 
$opt2total = ($opt2score1 + $opt2score2 + $opt2score3 + $opt2score4); 
//opt3 
$opt3aic = array_key_exists('aic3', $_POST) ? $_POST['aic3'] : null; 
$opt3batchcode = array_key_exists('batchcode3', $_POST) ? $_POST['batchcode3'] : null; 
$opt3name = array_key_exists('name3', $_POST) ? $_POST['name3'] : null; 
$opt3score1 = array_key_exists('optA3', $_POST) ? $_POST['optA3'] : null; 
$opt3score2 = array_key_exists('optB3', $_POST) ? $_POST['optB3'] : null; 
$opt3score3 = array_key_exists('optC3', $_POST) ? $_POST['optC3'] : null; 
$opt3score4 = array_key_exists('optD3', $_POST) ? $_POST['optD3'] : null; 
$opt3total = ($opt3score1 + $opt3score2 + $opt3score3 + $opt3score4); 
//opt4 
$opt4aic = array_key_exists('aic4', $_POST) ? $_POST['aic4'] : null; 
$opt4batchcode = array_key_exists('batchcode4', $_POST) ? $_POST['batchcode4'] : null; 
$opt4name = array_key_exists('name4', $_POST) ? $_POST['name4'] : null; 
$opt4score1 = array_key_exists('optA4', $_POST) ? $_POST['optA4'] : null; 
$opt4score2 = array_key_exists('optB4', $_POST) ? $_POST['optB4'] : null; 
$opt4score3 = array_key_exists('optC4', $_POST) ? $_POST['optC4'] : null; 
$opt4score4 = array_key_exists('optD4', $_POST) ? $_POST['optD4'] : null; 
$opt4total = ($opt4score1 + $opt4score2 + $opt4score3 + $opt4score4); 
//opt5 
$opt5aic = array_key_exists('aic5', $_POST) ? $_POST['aic5'] : null; 
$opt5batchcode = array_key_exists('batchcode5', $_POST) ? $_POST['batchcode5'] : null; 
$opt5name = array_key_exists('name5', $_POST) ? $_POST['name5'] : null; 
$opt5score1 = array_key_exists('optA5', $_POST) ? $_POST['optA5'] : null; 
$opt5score2 = array_key_exists('optB5', $_POST) ? $_POST['optB5'] : null; 
$opt5score3 = array_key_exists('optC5', $_POST) ? $_POST['optC5'] : null; 
$opt5score4 = array_key_exists('optD5', $_POST) ? $_POST['optD5'] : null; 
$opt5total = ($opt5score1 + $opt5score2 + $opt5score3 + $opt5score4); 
//opt6 
$opt6aic = array_key_exists('aic6', $_POST) ? $_POST['aic6'] : null; 
$opt6batchcode = array_key_exists('batchcode6', $_POST) ? $_POST['batchcode6'] : null; 
$opt6name = array_key_exists('name6', $_POST) ? $_POST['name6'] : null; 
$opt6score1 = array_key_exists('optA6', $_POST) ? $_POST['optA6'] : null; 
$opt6score2 = array_key_exists('optB6', $_POST) ? $_POST['optB6'] : null; 
$opt6score3 = array_key_exists('optC6', $_POST) ? $_POST['optC6'] : null; 
$opt6score4 = array_key_exists('optD6', $_POST) ? $_POST['optD6'] : null; 
$opt6total = ($opt6score1 + $opt6score2 + $opt6score3 + $opt6score4); 
//opt7 
$opt7aic = array_key_exists('aic7', $_POST) ? $_POST['aic7'] : null; 
$opt7batchcode = array_key_exists('batchcode7', $_POST) ? $_POST['batchcode7'] : null; 
$opt7name = array_key_exists('name7', $_POST) ? $_POST['name7'] : null; 
$opt7score1 = array_key_exists('optA7', $_POST) ? $_POST['optA7'] : null; 
$opt7score2 = array_key_exists('optB7', $_POST) ? $_POST['optB7'] : null; 
$opt7score3 = array_key_exists('optC7', $_POST) ? $_POST['optC7'] : null; 
$opt7score4 = array_key_exists('optD7', $_POST) ? $_POST['optD7'] : null; 
$opt7total = ($opt7score1 + $opt7score2 + $opt7score3 + $opt7score4); 
//opt8 
$opt8aic = array_key_exists('aic8', $_POST) ? $_POST['aic8'] : null; 
$opt8batchcode = array_key_exists('batchcode8', $_POST) ? $_POST['batchcode8'] : null; 
$opt8name = array_key_exists('name8', $_POST) ? $_POST['name8'] : null; 
$opt8score1 = array_key_exists('optA8', $_POST) ? $_POST['optA8'] : null; 
$opt8score2 = array_key_exists('optB8', $_POST) ? $_POST['optB8'] : null; 
$opt8score3 = array_key_exists('optC8', $_POST) ? $_POST['optC8'] : null; 
$opt8score4 = array_key_exists('optD8', $_POST) ? $_POST['optD8'] : null; 
$opt8total = ($opt8score1 + $opt8score2 + $opt8score3 + $opt8score4); 
//opt9 
$opt9aic = array_key_exists('aic9', $_POST) ? $_POST['aic9'] : null; 
$opt9batchcode = array_key_exists('batchcode9', $_POST) ? $_POST['batchcode9'] : null; 
$opt9name = array_key_exists('name9', $_POST) ? $_POST['name9'] : null; 
$opt9score1 = array_key_exists('optA9', $_POST) ? $_POST['optA9'] : null; 
$opt9score2 = array_key_exists('optB9', $_POST) ? $_POST['optB9'] : null; 
$opt9score3 = array_key_exists('optC9', $_POST) ? $_POST['optC9'] : null; 
$opt9score4 = array_key_exists('optD9', $_POST) ? $_POST['optD9'] : null; 
$opt9total = ($opt9score1 + $opt9score2 + $opt9score3 + $opt9score4); 
//opt10 
$opt10aic = array_key_exists('aic10', $_POST) ? $_POST['aic10'] : null; 
$opt10batchcode = array_key_exists('batchcode10', $_POST) ? $_POST['batchcode10'] : null; 
$opt10name = array_key_exists('name10', $_POST) ? $_POST['name10'] : null; 
$opt10score1 = array_key_exists('optA10', $_POST) ? $_POST['optA10'] : null; 
$opt10score2 = array_key_exists('optB10', $_POST) ? $_POST['optB10'] : null; 
$opt10score3 = array_key_exists('optC10', $_POST) ? $_POST['optC10'] : null; 
$opt10score4 = array_key_exists('optD10', $_POST) ? $_POST['optD10'] : null; 
$opt10total = ($opt10score1 + $opt10score2 + $opt10score3 + $opt10score4); 

$username = mysql_real_escape_string($_SESSION['username']); 
$repcode = mysql_real_escape_string($_SESSION['repcode']); 
$position = mysql_real_escape_string($_POST['position']); 
$division = mysql_real_escape_string($_POST['division']); 
$sgrade = mysql_real_escape_string($_POST['sgrade']); 
$salary = mysql_real_escape_string($_POST['salary']); 

//insert 1 
if($opt1aic != "" && $opt1batchcode != "" && $opt1name != "" && $opt1score1 != "" && $opt1score2 != "" && $opt1score3 != "" && $opt1score4 != "" && $opt1total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt1aic','$opt1batchcode','$position','$division','$sgrade','$salary','$opt1name','$opt1score1','$opt1score2','$opt1score3','$opt1score4','$opt1total',CURRENT_TIMESTAMP)"); 
} 
//insert 2 
if($opt2aic != "" && $opt2batchcode != "" && $opt2name != "" && $opt2score1 != "" && $opt2score2 != "" && $opt2score3 != "" && $opt2score4 != "" && $opt2total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt2aic','$opt2batchcode','$position','$division','$sgrade','$salary','$opt2name','$opt2score1','$opt2score2','$opt2score3','$opt2score4','$opt2total',CURRENT_TIMESTAMP)"); 
} 
//insert 3 
if($opt3aic != "" && $opt3batchcode != "" && $opt3name != "" && $opt3score1 != "" && $opt3score2 != "" && $opt3score3 != "" && $opt3score4 != "" && $opt3total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt3aic','$opt3batchcode','$position','$division','$sgrade','$salary','$opt3name','$opt3score1','$opt3score2','$opt3score3','$opt3score4','$opt3total',CURRENT_TIMESTAMP)"); 
} 
//insert 4 
if($opt4aic != "" && $opt4batchcode != "" && $opt4name != "" && $opt4score1 != "" && $opt4score2 != "" && $opt4score3 != "" && $opt4score4 != "" && $opt4total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt4aic','$opt4batchcode','$position','$division','$sgrade','$salary','$opt4name','$opt4score1','$opt4score2','$opt4score3','$opt4score4','$opt4total',CURRENT_TIMESTAMP)"); 
} 
//insert 5 
if($opt5aic != "" && $opt5batchcode != "" && $opt5name != "" && $opt5score1 != "" && $opt5score2 != "" && $opt5score3 != "" && $opt5score4 != "" && $opt5total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt5aic','$opt5batchcode','$position','$division','$sgrade','$salary','$opt5name','$opt5score1','$opt5score2','$opt5score3','$opt5score4','$opt5total',CURRENT_TIMESTAMP)"); 
} 
//insert 6 
if($opt6aic != "" && $opt6batchcode != "" && $opt6name != "" && $opt6score1 != "" && $opt6score2 != "" && $opt6score3 != "" && $opt6score4 != "" && $opt6total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt6aic','$opt6batchcode','$position','$division','$sgrade','$salary','$opt6name','$opt6score1','$opt6score2','$opt6score3','$opt6score4','$opt6total',CURRENT_TIMESTAMP)"); 
} 
//insert 7 
if($opt7aic != "" && $opt7batchcode != "" && $opt7name != "" && $opt7score1 != "" && $opt7score2 != "" && $opt7score3 != "" && $opt7score4 != "" && $opt7total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt7aic','$opt7batchcode','$position','$division','$sgrade','$salary','$opt7name','$opt7score1','$opt7score2','$opt7score3','$opt7score4','$opt7total',CURRENT_TIMESTAMP)"); 
} 
//insert 8 
if($opt8aic != "" && $opt8batchcode != "" && $opt8name != "" && $opt8score1 != "" && $opt8score2 != "" && $opt8score3 != "" && $opt8score4 != "" && $opt8total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt8aic','$opt8batchcode','$position','$division','$sgrade','$salary','$opt8name','$opt8score1','$opt8score2','$opt8score3','$opt8score4','$opt8total',CURRENT_TIMESTAMP)"); 
} 
//insert 9 
if($opt9aic != "" && $opt9batchcode != "" && $opt9name != "" && $opt9score1 != "" && $opt9score2 != "" && $opt9score3 != "" && $opt9score4 != "" && $opt9total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt9aic','$opt9batchcode','$position','$division','$sgrade','$salary','$opt9name','$opt9score1','$opt9score2','$opt9score3','$opt9score4','$opt9total',CURRENT_TIMESTAMP)"); 
} 
//insert 10 
if($opt10aic != "" && $opt10batchcode != "" && $opt10name != "" && $opt10score1 != "" && $opt10score2 != "" && $opt10score3 != "" && $opt10score4 != "" && $opt10total != ""){ 
mysql_query("INSERT INTO app_interview (intrepcode,atic,atbatchcode,position,division,sgrade,salary,atname,gen_info,com_ability,attitude,appearance,inttotal,dateinterviewed) VALUES ('$repcode','$opt10aic','$opt10batchcode','$position','$division','$sgrade','$salary','$opt10name','$opt10score1','$opt10score2','$opt10score3','$opt10score4','$opt10total',CURRENT_TIMESTAMP)"); 
} 

    header("Location:interview.php"); 
} 

?> 

我想從的frm1保存到frm10..can任何人幫我請。

+1

*「數據需要救援」* ---看起來像一個「致電911-Code-Busters」的工作 –

+1

老兄,你不是真的要複製所有的代碼,是嗎?考慮一些循環。 – user1032531

+0

@ user1032531:循環使控制流複雜化,並且可能嚴重損害具有分層高速緩存的現代無序流水線體系結構的性能。研究如何改進現代硬件性能的控制依賴彈出*有一個不斷增長的領域。看起來OP在這裏應用這些知識。 –

回答

0

那是因爲他們不是形式的一部分......

<form>裏面只有字段您提交的提交!

+0

但我認爲它們都是在窗體內?O.o frm1是如何才能在數據庫中保存的唯一一個? – user3235574

+0

他們都在同一個'

'?不,他們不是。 –

+0

我剛剛通過刪除我的迷你表格frm1-frm10 ..解決了我自己的問題。並且改變了我的javascript功能...感謝您的時間。 – user3235574