I have 2 pages one displaying a form from a database, which allows a user to change the status of a job via a drop down box, see Page1.php code below
Page1.php
This code now posts the variables to Page2.php and processes it i.e.
Page2.php
The problem with this code is that it outputs,
where as i just want it to update
if i output the array structure and values i.e.
it returns
Im pretty sure the problem is within the foreach loop,
Any suggestions on how i can achieve this, without it looping again?
Thanks in Advance and i hope this makes sense.
Page1.php
Code:
while($row = mysql_fetch_array($result))
{
echo "<tr align='center'>\n";
extract($row);
echo '<td>
<select name="AwaitingStatus[]" class="body">
<option value="">Change Status...</option>
<option value="P">Awaiting Spare Parts</option>
<option value="U">Awaiting Tools/Equipment</option>
<option value="K">Awaiting Mod Kits</option>
<option value="I">Awaiting Inspection</option>
<option value="V">Awaiting Tech. Services</option>
<option value="B">Awaiting Access</option>
<option value="Q">Awaiting Other Staff/Jobs</option>
<option value="F">Change of Priority</option>
<option value="E">Card Completion</option>
<option value="X">System Fault</option>
<option value="Z">Awaiting Planning</option>
</select></td>';
echo "<td>".$row['jobTitle']."</td>\n";
echo "<input type='hidden' name='hidvar[]' value='$jobCode'";
echo "</tr>\n";
}
Page2.php
Code:
foreach ($AwaitingStatus as $JobStatus) //Checks for Status Change
{
foreach ($jobCode as $Code)
{
$sql3 = "UPDATE joblist SET LostTime = '$JobStatus' WHERE jobCode = '$Code'";
$Code = mysql_query($sql3);
echo $sql3.'<br>';
}
echo "<br />";
}
Code:
UPDATE joblist SET LostTime = 'U' WHERE jobCode = 'CG162'
UPDATE joblist SET LostTime = 'U' WHERE jobCode = 'RS976'
UPDATE joblist SET LostTime = 'I' WHERE jobCode = 'CG162'
UPDATE joblist SET LostTime = 'I' WHERE jobCode = 'RS976'
Code:
UPDATE joblist SET LostTime = 'I' WHERE jobCode = 'RS976'
UPDATE joblist SET LostTime = 'U' WHERE jobCode = 'CG162'
Code:
print_r ($AwaitingStatus);
print_r ($jobCode);
Code:
Array ( [0] => U [1] => I ) Array ( [0] => CG162 [1] => RS976 )
Code:
foreach ($AwaitingStatus as $JobStatus)
{
foreach ($jobCode as $Code)
{
}
}
Thanks in Advance and i hope this makes sense.