Hi all,
I have created the following form. But the $PID_final_mark doesn't POST to modassess.php. The variable is the total of a calculation performed in the form. A hidden input is included for $PID_final_mark. SO am unsure what else could be causing the problem. The update statement is included after the code:
<form name="PID" method="post" action="modassess.php?action=addPID">
<input type="hidden" name="PID_final_mark" value="<?php echo $PID_final_mark; ?>">
<input type="hidden" name="hidden_project_id" value="<?php echo $projectid; ?>">
<input type="hidden" name="hidden_assess_id" value="<?php echo $assessid; ?>">
<table width="100%" border="0">
<tr bgcolor="#9AB6F8">
<th width="20%" bgcolor="#9AB6F8" scope="col"><div align="center" class="style2">
<div align="center">Project Section </div>
</div></th>
<th width="20%" bgcolor="#9AB6F8" scope="col"><div align="center" class="style2">
<div align="center">PID Sub-Section </div>
</div></th>
<th width="20%" bgcolor="#9AB6F8" scope="col"><div align="center" class="style2">
<div align="center">Assessment Mark </div>
</div></th>
<th width="20%" bgcolor="#9AB6F8" class="style2" scope="col">Current PID Mark</th>
</tr>
<tr>
<th width="20%" rowspan="3" bgcolor="F2F2FF" scope="row"><span class="style2">Project Initiation Document</span></th>
<td width="20%" bgcolor="E2E2F2"><div align="center" class="style2">Project Justification </div></td>
<td width="20%" bgcolor="F2F2FF"><div align="center" class="style2">
<input name="PID_project_just_mark" type="text" id="PID_project_just_mark" size="4" maxlength="2">
/ 25 </div></td>
<td width="20%" bgcolor="F2F2FF" class="style2"><div align="center"><?php echo $rs['PID_project_just_mark']; ?> / 25</div></td>
</tr>
<tr>
<td width="20%" bgcolor="E2E2F2">
<div align="center" class="style2">Project Approach/Plans</div></td>
<td width="20%" bgcolor="F2F2FF"><div align="center" class="style2">
<input name="PID_project_approach_plans_mark" type="text" id="PID_project_approach_plans_mark" size="4" maxlength="2">
/ 50</div></td>
<td width="20%" bgcolor="F2F2FF" class="style2"><div align="center"><?php echo $rs['PID_project_approach_plans_mark']; ?> / 50 </div></td>
</tr>
<tr>
<td width="20%" bgcolor="E2E2F2"><div align="center" class="style2">Research</div></td>
<td width="20%" bgcolor="F2F2FF"><div align="center" class="style2">
<input name="PID_research_mark" type="text" id="PID_research_mark" size="4" maxlength="2">
/ 25 </div></td>
<td width="20%" bgcolor="F2F2FF" class="style2"><div align="center"><?php echo $rs['PID_research_mark']; ?> / 25 </div></td>
<td width="10%" rowspan="3" bgcolor="F2F2FF"><div align="center" class="style2">
<?php
$PID_final_mark = (intval($rs['PID_project_just_mark']) + intval($rs['PID_project_approach_plans_mark']) + intval($rs['PID_research_mark']));
?>
<input name="Add PID Marks" type="submit" id="Add PID Marks" value="Add">
</div></td>
</form>
<td width="10%" rowspan="3" bgcolor="F2F2FF">
<form name="REMOVE PID" action="modassess.php?action=removePID" method="post">
<div align="center" class="style2"><input name="Remove PID Marks" align="middle" type="submit" id="Remove PID Marks" value="Remove"></div>
<input type="hidden" name="hidden_project_id" value=<?php echo $projectid; ?>>
<input type="hidden" name="hidden_assess_id" value=<?php echo $assessid; ?>>
</form>
Here is the update statement using a switch case method:
if (isset($_POST['PID_final_mark'])) {
$PID_final_mark = $_POST['PID_final_mark'];
}
switch($_GET["action"]) {
case "addPID":
$query = "UPDATE project_assess
SET PID_project_just_mark ='$PID_project_just_mark',
PID_project_approach_plans_mark='$PID_project_approach_plans_mark',
PID_research_mark='$PID_research_mark',
PID_final_mark='$PID_final_mark'
WHERE project_assess_ID='$assessid'
AND project_ID='$projectid' "; echo $query;
$redirect = "assessproject.php?assessid=$assessid&projectid=$projectid";
break;