I am making a trial database for a small escalation form. The only requirements for this is that the values for the 4 select boxes present must be numbers.
Any of the 4 can be changed at any time.
When any combination of them are changed, I want to put in the documentation field "field 1 was changed to $field_1" etc, but ONLY if it was changed. I can do this, however my values for $field_x are numbers which will be meaningless to anyone, other than myself, reading the documentation.
I've set the update function in the action switch on the page under case "update".
I have the original values pulled and selected in the select boxes and a hidden variable in the form titled $field_x_chk so I can see if any of the values where changed when the form was submitted.
Here is the code for the update section of the form: (Its a bit messy, and if you have any recommendations on how I could clean it up, I'd definitely like any assistance.)
<TABLE border="0" width=100%>
<TR>
<td class=header>Assigned To:</td>
<td class=normal>
<form name="main2" action='med_escals1.php' method='post'>
<input type=hidden name=action value=update>
<input type=hidden name=id value=<?=$id;?>>
<SELECT name="assigned_to">
<OPTION value=""></option>
<?
if($res['assigned_to']==1) {
$assign_current="Texas";
}elseif($res['assigned_to']==2) {
$assign_current="Ohio";
}elseif($res['assigned_to']==3) {
$assign_current="Tennessee";
}
$center_val[0]="1";
$center_val[1]="2";
$center_val[2]="3";
$centers[0]="Texas";
$centers[1]="Ohio";
$centers[2]="Tennessee";
for($i=0; $i<count($centers); $i++){
print "<option value='".$center_val[$i]."' ";
if($centers[$i]==$assign_current)
print " selected ";
print ">".$centers[$i]."</option>";
}
?>
</SELECT>
</td>
<TD class=header>Tkt Status:</TD>
<TD class=normal>
<select name=tkt_status>
<option value=""></option>
<?
if($res['tkt_status']==0) {
$tkt_current="Open";
}elseif($res['tkt_status']==1) {
$tkt_current="In Progress";
}elseif($res['tkt_status']==2) {
$tkt_current="Closed";
}
$stat_val[0]="0";
$stat_val[1]="1";
$stat_val[2]="2";
$status[0]="In Progress";
$status[1]="Open";
$status[2]="Closed";
for($i=0; $i<count($status); $i++){
print "<option value='".$stat_val[$i]."' ";
if($status[$i]==$tkt_current)
print " selected ";
print ">".$status[$i]."</option>";
}
?>
</TD>
<td class=header>RMA Status:</td>
<td class=normal>
<select name='rma_status'>
<?
if($res['rma_status']==1) {
$rma_current="Awaiting Part";
}elseif($res['rma_status']==2) {
$rma_current="Customer Abuse";
}elseif($res['rma_status']==3) {
$rma_current="Address Change";
}elseif($res['rma_status']==4) {
$rma_current="Unknown Part";
}elseif($res['rma_status']==5) {
$rma_current="Shipped";
}elseif($res['rma_status']==6) {
$rma_current="Substitute Part";
}elseif($res['rma_status']==7) {
$rma_current="Status Change";
}elseif($res['rma_status']==8) {
$rma_current="Other";
}
$rma_val[0]=0;
$rma_val[1]=1;
$rma_val[2]=2;
$rma_val[3]=3;
$rma_val[4]=4;
$rma_val[5]=5;
$rma_val[6]=6;
$rma_val[7]=7;
$rma_stat[0]="Awaiting Part";
$rma_stat[1]="Customer Abuse";
$rma_stat[2]="Address Change";
$rma_stat[3]="Unknown Part";
$rma_stat[4]="Shipped";
$rma_stat[5]="Substitute Part";
$rma_stat[6]="Status Change";
$rma_stat[7]="Other";
for($i=0; $i<count($rma_stat); $i++){
print "<option value='".$rma_val[$i]."' ";
if($rma_stat[$i]==$rma_current)
print " selected ";
print ">".$rma_stat[$i]."</option>";
}
?>
</select>
</td>
<td class=header>Priority:</td>
<td class=normal><select name=priority>
<option value=""></option>
<?
if($res['priority']==1) {
$priority_curr="Low";
}elseif($res['priority']==2) {
$priority_curr="High";
}
$priority_val[0]=1;
$priority_val[1]=2;
$priority_stat[0]="Low";
$priority_stat[1]="High";
for($i=0; $i<count($priority_stat); $i++){
print "<option value='".$priority_val[$i]."' ";
if($priority_stat[$i]==$priority_curr)
print " selected ";
print ">".$priority_stat[$i]."</option>";
}
?> </select>
</td>
<td class=header><input type=submit value="Update">
<input type=hidden name='assign_chk' value="<?=$res['assigned_to'];?>"><input type='hidden' name='tkt_chk' value="<?=$res['tkt_status'];?>">
<input type=hidden name='rma_chk' value="<?=res['rma_status'];?>"><input type='hidden' name='priority' value="<?=$res['priority'];?>"> </td>
</TR>
</TABLE>
I need help with 1) checking the changed fields individually 2)putting each one seperately (if changed) into the documentation field ($rma_doc) with the proper description instead of a number
I was thinking about assigning each of the fields to an array and entering that array into the database-- would that be efficient or even work the way I want?
I know this is a bit confusing, if you need clarification let me know and I'll try to explain better. Thanx very much for the help
Nico