Man of Honour
Also, to let the user choose yes/no, you need a radio button or two
if ($_GET['1'] = done) {
mysql_query("
UPDATE help_desk
SET done = 'yes'
WHERE id = 1
");
} else {
};
Trigger said:Code:if ($_GET['1'] = done)
Trigger said:Code:else { };
<?php
switch($_GET['action']) {
case 'delete':
// SQL stuff here...
header('Location: backWhereTheyCameFrom.php');
break; // break is unecessary here, but leave it in.
case 'completed':
mysql_query('UPDATE help_desk ' .
'SET done = "yes" ' .
'WHERE id = '.intval($_GET['id']);
header('Location: backWhereTheyCameFrom.php');
break;
// etc, etc...
}
?>
Trigger said:Right, thanks I've thought about this before, but what if the user checks a radio box in more than one row?
Thanks
Ben
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ruskin Sports College .::. HelpDesk™</title>
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="login">
<p class="logintitle">
Ruskin Sports College .::. HelpDesk™ Administrator Interface
</p>
<p class="viewdesk" align="center">
<?php
// Create Database Variables:
$host = "localhost";
$user = "******";
$pass = "********";
$dbase = "helpdesk";
// Connect to Database:
$connection = mysql_connect($host, $user, $pass) or die('Could not connect to Database');
// Select Database:
mysql_select_db($dbase) or die('Could not find selected database');
$query = "SELECT * FROM help_desk";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<center";
echo "<center><font color=green><div id=tables><table cellpadding=10 border=1 align=center>";
echo "<tr>";
echo "<td><font color=red> ID Number</font></td>";
echo "<td><font color=red> Submitted by User</font></td>";
echo "<td><font color=red> Problem Location</font></td>";
echo "<td><font color=red> Type </font></td>";
echo "<td><font color=red> Urgent </td>";
echo "<td><font color=red> Problem Description </font></td>";
echo "<td><font color=purple> Done </font></td>";
echo "<td><font color=red> Actions </font></td>";
echo "</tr>";
while($row = mysql_fetch_array($result)) {
$id = $row[id];
global $id;
global $row;
echo "<tr>";
$urgent = $row[urgent];
$done = $row[done];
echo "<td>" . $row[id]."</td>";
echo "<td>" . $row[user]."</td>";
echo "<td>".$row[location]."</td>";
echo "<td>".$row[type]."</td>";
if ($urgent == "Yes") {
echo "<td><font color=red><img src=img/urgent.jpg></img></font></td>";
}
elseif ($urgent == "No") {
echo "<td><font color=blue>". $urgent; "</td>";
} else {
}
echo "<td>".$row[problem]."</td>";
if ($done == "yes") {
echo "<td><font color=red><img src=img/done.jpg></img></font></td>";
}
elseif ($done == "no") {
echo "<td><font color=blue><img src=img/cross.gif></img></font></td>";
} else {
}
echo "<td><form action='u8w6y58irfhfiwe794.php' method=get><font face=tahoma color=blue>Done:<input type=radio name='$row[id]' value=done><br />Delete:<input type=radio name='$row[id]' value=delete></font></td>";
echo "</tr>";
}
echo "</table></div>";
}
else {
// no
// print status message
echo "No New Problems have been submitted to the HelpDesk!";
}
$row = mysql_fetch_array($result);
$id = $row[id];
echo $id;
function updatedone($idacc) { mysql_query("
UPDATE help_desk
SET done = 'yes'
WHERE id = '$idacc'
");
};
updatedone(3);
echo $row;
echo "</p><p>";
echo "<input type=submit value=Update onClick=alert('Are you sure?')</input>";
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
?>
</p>
<p>
<form>
<input type="button" value="Return to Main Menu" onClick="window.location='d4ttg4689hjyhjjsjyhweqwlkml.php'""></input>
</form>
</p>
<br /><br />
</body>
</html>
Trigger said:
robmiller said:Do you see my point about comments? They're showing you, the reader of the tutorial, what each segment of code is doing. Once you've learned the language (which you will, quickly) such comments become tiresome and unnecessary, so it's better to leave them out