Would anyone be able to help me with the problem I'm having with the following code please?
I have a table of data, including FaultID, ComputerID etc, listing all faults in the database currently with the status "Attention". The purpose of this form is to assign a Priority to each of these listed faults, which will obviously update the database record.
I think this is the offending code:
There is no response from the php code when I click "SUBMIT" - it simply refreshes the page.
The entire code is as follows:
Thanks everyone.
I have a table of data, including FaultID, ComputerID etc, listing all faults in the database currently with the status "Attention". The purpose of this form is to assign a Priority to each of these listed faults, which will obviously update the database record.
I think this is the offending code:
Code:
if (isset($_POST['FaultPriority'])){
// The author's details have been updated.
$id = $_POST['id'];
$ComputerID = $_POST['ComputerID'];
$FaultPriority = $_POST['FaultPriority'];
$sql = "UPDATE Fault SET
FaultPriority=$FaultPriority
WHERE ComputerID='$ComputerID'";
if (@mysql_query($sql)) {
echo '<p>Workstation details updated.</p>';
} else {
echo '<p>Error updating workstation details: ' .
mysql_error() . '</p>';
}
}
There is no response from the php code when I click "SUBMIT" - it simply refreshes the page.
The entire code is as follows:
Thanks everyone.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Helpdesk : All workstations requiring attention</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Manage Workstations</h1>
<?php
$dbcnx = @mysql_connect('localhost', 'root', '');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!@mysql_select_db('Technician_Support')) {
exit('<p>Unable to locate the helpdesk ' .
'database at this time.</p>');
}
if (isset($_POST['FaultPriority'])){
// The author's details have been updated.
$id = $_POST['id'];
$ComputerID = $_POST['ComputerID'];
$FaultPriority = $_POST['FaultPriority'];
$sql = "UPDATE Fault SET
FaultPriority=$FaultPriority
WHERE ComputerID='$ComputerID'";
if (@mysql_query($sql)) {
echo '<p>Workstation details updated.</p>';
} else {
echo '<p>Error updating workstation details: ' .
mysql_error() . '</p>';
}
}
// The basic SELECT statement
$select = 'SELECT FaultID, ComputerID, FaultStatus, FaultType, FaultDescription, StaffID, TechID, FaultPriority';
$from = ' FROM Fault';
$where = ' WHERE FaultStatus="Attention"';
$orderby = ' ORDER BY FaultID';
$sid = '100';
$roomid = '101';
?>
<?php
echo "<table cellpadding=0, cellspacing=0 border=1 align=center><tr>\n";
echo '<td width="90" align=center> Fault ID </td> <td width="90" align=center> Computer ID </td> <td width="90" align=center> Fault Type </td> <td width="200" align=center> Fault Description </td> <td width="90" align=center> Staff ID </td> <td width="90" align=center> Technician ID </td> <td width="90" align=center> Fault Priority </td>';
echo '</tr>'.'</table>';
$workstations = @mysql_query($select . $from . $where . $orderby);
if ($workstations) {
echo "<table cellpadding=0, cellspacing=0 align=center border=1><tr valign='top'>\n";
$statuses = array("Working","Attention","Faulty");
$counter = 0;
$faulty = 0;
$attention = 0;
$working = 0;
$str = "";
while ($computer = mysql_fetch_assoc($workstations)) {
if (($counter) >= 1) {
$str .= '</tr><tr valign="top">';
}
$counter++;
$status = htmlentities($computer['FaultStatus']);
$FaultID = $computer['FaultID'];
$ComputerID = $computer['ComputerID'];
$FaultType = $computer['FaultType'];
$FaultDescription = $computer['FaultDescription'];
$StaffID = $computer['StaffID'];
$TechID = $computer['TechID'];
$FaultPriority = $computer['FaultPriority'];
if(in_array($status,$statuses)){
$str .= '<td width="90">'.$FaultID.'</td>'.'<td width="90">'.$ComputerID.'</td>'.'<td width="90">'.$FaultType.'</td>'.'<td width="200">'.$FaultDescription.'</td>'.'<td width="90">'.$StaffID.'</td>'.'<td width="90">'.$TechID.'</td>'.'<td width="90">'.'<select size="1" name="FaultPriority">
<option value="Not Set" selected> Not Set </option>
<option value="High"> High </option>
<option value="Medium"> Medium </option>
<option value="Low"> Low </option>/td>';
} else {
$str .= '<td align="center">-</td>';
}
}
$str .= '</tr></table>';
echo $str;
}
?>
<form method="post" action="">
<input type="Submit" name="submit" value="Submit">
</form>
<p><a href="stations.php">New search</a></p>
</body>
</html>