無法查出是什麼問題...比如我想添加2行數據的...當我按下+按鈕...我的數據剛鍵入會(看起來像刷新)...數據庫將只存儲第二行數據...第一個不會存儲。請幫我找出答案。謝謝〜添加一組新數據,並存儲到數據庫
<?php if($_POST['btnPlus1'])
$_SESSION['count1'] += 1;
else if($_POST['btnMinus1'])
$_SESSION['count1'] -= 1;
$AddEducationalQ = "INSERT INTO tbleducational(Id,University,Level,Specialization,Year) VALUES('".$_POST['txtStaffIc']."','".strtoupper($_POST['txtUniversity'])."','".strtoupper($_POST['sLevel'])."','".strtoupper($_POST['txtSpecialization'])."','".$_POST['txtYear']."')";
$AddEducationalResult = mysql_query($AddEducationalQ,$link); ?>
<tr>
<td>
<fieldset>
<legend>Educational Background</legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php
for($tempfield = 1; $tempfield <= $_SESSION['count1']; ++$tempfield)
{?>
<fieldset>
<legend><?php echo $tempfield ?></legend>
<table width="200" border="0">
<tr>
<td>University</td>
<td>Level</td>
<td>Specialization</td>
<td>Year Graduated</td>
</tr>
<tr>
<td>
<input type="text" name="txtUniversity" id="txtUniversity" /></td>
<td>
<select name="sLevel" id="sLevel">
<option></option>
<option>Diploma</option>
<option>Degree</option>
<option>Master</option>
<option>Doctor</option>
</select>
</td>
<td>
<input type="text" name="txtSpecialization" id="txtSpecialization" />
</td>
<td>
<input type="text" name="txtYear" id="txtYear" />
</td>
</tr>
</table>
</fieldset>
<?php
}?>
</td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" name="btnPlus1" id="btnPlus1" value="+" /> <input type="submit" name="btnMinus1" id="btnMinus1" value="-" /></td>
</tr>
</table>
</fieldset>
</td>
</tr>
我失去了你的部分代碼。你的表單元素在哪裏?你的第一張桌子的開始在哪裏? – icecub 2014-10-12 06:27:52
只是簡單的
– phpnewbie123 2014-10-12 06:45:35葉難怪它不工作..我會看看我能不能想些辦法 – icecub 2014-10-12 06:46:47