Hello,
I’ve got a website page entitled “editroster.php”. This page includes three tables with a list of users and other parameters involved. I need to able to be able to move users between all three tables.
The code in question occours between lines 152 to 181, I believe. It’s a little messed up right now because I’ve been fiddling with it. I thought perhaps using the php “switch” command was the way to go but it doesn’t appear to be working. In the end, like I said, I need to be able to move users (with status’ either 1, 2 or 3) between all three tables (1, 2 or 3).
Make sense?
Thanks for your help.
[php]
…
// MAIN CONTENT
$a = $_GET[‘a’];
if ($a == “edituser”) {
$a2 = $_GET[‘a2’];
if ($a2 == “delete”) {
// DELETE CONTENT
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM controllers WHERE cid='$id' LIMIT 1");
if (mysql_num_rows($result) == 0) {
$content = 'Sorry but the user with the ID <b>#' . $id . '</b> could not be located in the database.<br>Please go back and try again.';
} else {
$confirm = $_GET['confirm'];
if ($confirm == "true") {
// COMPLETE DELETION
$query = "DELETE FROM `controllers` WHERE cid='$id' LIMIT 1";
mysql_query($query);
logaction($id, 'was DELETED');
$content = '<center>User successfully deleted.<br>You will now be redirected back to the roster.<meta http-equiv="refresh" content="3; url=?page=editroster">';
} else {
$content = '
<b>Please confirm: Are you sure you wish to delete this user?</b><br><br>
<table width="75%" cellspacing="0" cellpadding="0">
<tr height="50">
<td colspan="2" class="profilebox2" align="center">The user <b>' . showname($id) . ' </b>(<b>' . $id . '</b>) will be deleted.<br><br>Please note: THIS CAN NOT BE UNDONE!!<br></td>
</tr>
<tr height="30" align="center">
<td valign="top" class="profilebox2" width="50%" align="center"><table width="60%" height="25"><tr><td class="notaminside" align="center" style="BORDER: #000000 1px solid"><a href="javascript:confirmDelete(\'?page=editroster&a=edituser&a2=delete&id=' . $id . '&confirm=true\')"><b>Confirm<br>Deletion</b></a></td></tr></table></td>
<td valign="top" class="profilebox2" width="50%" align="center"><table width="60%" height="25"><tr><td class="notaminside" align="center" style="BORDER: #000000 1px solid"><a href="?page=editroster"><b>Abort<br>Deletion</b></a></td></tr></table> </td>
</tr>
</table>
';
}
}
} else if ($a2 == "promote") {
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM controllers WHERE cid='$id' LIMIT 1");
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0) {
$content = 'Sorry but the user with the ID <b>#' . $id . '</b> could not be located in the database.<br>Please go back and try again.';
} else {
$nr = $_GET['nr'];
// Promote
if ($nr == "") {
$content = 'Please select a new rating to promote this controller to.';
} else {
$confirm = $_GET['confirm'];
if ($confirm == "true") {
$or = $row['rating'];
$upd = "UPDATE `controllers` SET rating='$nr' WHERE cid='$id' LIMIT 1";
mysql_query($upd);
$time = time();
$ins = "INSERT INTO `promotions` (`cid`, `date`, `time`, `rating`) VALUES ('$id', now(), '$time', '$nr')";
mysql_query($ins);
logaction($id, 'was PROMOTED to ' . $nr);
//logaction('Controller ' . showname($id) . ' was PROMOTED to ' . $nr . ' by ' . showname($_SESSION['cid']));
$content = 'This user\'s rating has been successfully changed from <b>' . $or . '</b> to <b>' . $nr . '</b>.<br>You will now be redirected back to the profile page.<meta http-equiv="refresh" content="3; url=?page=editroster&a=edituser&id=' . $id .'">';
} else {
// Continue
$content = '
<b>Please confirm: Are you sure you wish to promote this user?</b><br><br>
<table width="85%" cellspacing="0" cellpadding="0">
<tr height="50">
<td colspan="2" class="profilebox2" align="center">The user <b>' . showname($id) . ' </b>(<b>' . $id . '</b>) will be promoted from <b>' . $row['rating'] . '</b> to <b>' . $nr . '</b>.<br><br></td>
</tr>
<tr height="30" align="center">
<td valign="top" class="profilebox2" width="50%" align="center"><table width="60%" height="25"><tr><td class="notaminside" align="center" style="BORDER: #000000 1px solid"><a href="?page=editroster&a=edituser&a2=promote&id=' . $id . '&nr=' . $nr . '&confirm=true"><b>Confirm<br>Promotion</b></a></td></tr></table></td>
<td valign="top" class="profilebox2" width="50%" align="center"><table width="60%" height="25"><tr><td class="notaminside" align="center" style="BORDER: #000000 1px solid"><a href="?page=editroster&a=edituser&id=' . $id . '"><b>Abort<br>Promotion</b></a></td></tr></table> </td>
</tr>
</table>
';
}
}
}
} else if ($a2 == "hv") {
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM controllers WHERE cid='$id' LIMIT 1");
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0) {
$content = 'Sorry but the user with the ID <b>#' . $id . '</b> could not be located in the database.<br>Please go back and try again.';
} else {
if ($row['status'] == 1) {
// CHANGE TO INACTIVE
$upd = "UPDATE `controllers` SET status='3' WHERE cid='$id' LIMIT 1";
mysql_query($upd);
logaction($id, 'was set to INACTIVE CONTROLLER');
//logaction('Controller ' . showname($id) . ' was set to INACTIVE CONTROLLER by ' . showname($_SESSION['cid']));
$content = 'Controller has now had <b>CYWG</b> set to <b>INACTIVE</b><br>You will now be redirected back to the profile page.<meta http-equiv="refresh" content="3; url=?page=editroster&a=edituser&id=' . $id . '">';
}
}
} else if ($a2 == "hv") {
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM controllers WHERE cid='$id' LIMIT 1");
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0) {
$content = 'Sorry but the user with the ID <b>#' . $id . '</b> could not be located in the database.<br>Please go back and try again.';
} else {
if ($row['status'] == 2) {
// CHANGE TO INACTIVE
$upd = "UPDATE `controllers` SET status='3' WHERE cid='$id' LIMIT 1";
mysql_query($upd);
logaction($id, 'was set to INACTIVE CONTROLLER');
//logaction('Controller ' . showname($id) . ' was set to INACTIVE CONTROLLER by ' . showname($_SESSION['cid']));
$content = 'Controller has now had <b>CYWG</b> set to <b>INACTIVE</b><br>You will now be redirected back to the profile page.<meta http-equiv="refresh" content="3; url=?page=editroster&a=edituser&id=' . $id . '">';
}
}
} else if ($a2 == "loa") {
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM controllers WHERE cid='$id' LIMIT 1");
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0) {
$content = 'Sorry but the user with the ID <b>#' . $id . '</b> could not be located in the database.<br>Please go back and try again.';
} else {
if ($row['LOA'] == 1) {
// CHANGE TO LOA
$upd = "UPDATE `controllers` SET status='2' WHERE cid='$id' LIMIT 1";
mysql_query($upd);
logaction($id, 'was put on LOA');
//logaction('Controller ' . showname($id) . ' was set to on LOA by ' . showname($_SESSION['cid']));
$content = 'Controller has now been set to <b>Leave of Absence</b><br>You will now be redirected back to the profile page.<meta http-equiv="refresh" content="3; url=?page=editroster&a=edituser&id=' . $id . '">';
} else {
// CHANGE TO NORMAL
$upd = "UPDATE `controllers` SET status='1' WHERE cid='$id' LIMIT 1";
mysql_query($upd);
logaction($id, 'was returned from LOA');
//logaction('Controller ' . showname($id) . ' was set to NORMAL ' . showname($_SESSION['cid']));
$content = 'Controller has now been returned from <b>Leave of Absence (LOA)</b><br>You will now be redirected back to the profile page.<meta http-equiv="refresh" content="3; url=?page=editroster&a=edituser&id=' . $id . '">';
}
}
} else if ($a2 == "inst") {
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM controllers WHERE cid='$id' LIMIT 1");
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0) {
$content = 'Sorry but the user with the ID <b>#' . $id . '</b> could not be located in the database.<br>Please go back and try again.';
} else {
.....
?>[/php]