$fn = $_POST['fn']; $ln = $_POST['ln']; $pos = $_POST['pos']; if ($id == 'add') { mysql_query("INSERT INTO " . $db_prefix . "members\n (firstName, lastName, position)\n VALUES ('{$fn}', '{$ln}', '{$pos}')", $con); $id = mysql_insert_id($con); $add = true; } else { mysql_query("UPDATE " . $db_prefix . "members\n SET firstName='{$fn}', lastName='{$ln}', position='{$pos}'\n WHERE id={$id}", $con); } $result = mysql_query("SELECT * FROM " . $db_prefix . "members WHERE id={$id}", $con); while ($row = mysql_fetch_array($result)) { if ($add) { echo "<li id=\"mem{$id}\">"; } formatMember($row); if ($add) { echo "</li>"; } } break; case 'memdel': mysql_query("DELETE FROM " . $db_prefix . "members WHERE id={$id}"); echo "<i>User Removed</i>"; break; case 'memmove': $id1 = $_POST['id1']; $id2 = $_POST['id2']; mysql_query("UPDATE " . $db_prefix . "members\n SET id=1000\n WHERE id={$id1}", $con); // If this breaks, then we are amazing mysql_query("UPDATE " . $db_prefix . "members\n SET id={$id1}\n WHERE id={$id2}", $con);
function memList() { global $con; global $db_prefix; sqlcon(); $result = mysql_query("SELECT * FROM " . $db_prefix . "members WHERE position!='' ORDER BY id", $con); $prevID = ''; $rowArray; $i = 0; while ($row = mysql_fetch_array($result)) { $rowArray[$i] = $row; $i++; } for ($j = 0; $j < $i; $j++) { $ID = $rowArray[$j]['id']; $nextID = $rowArray[$j + 1]['id']; echo "<li id=\"mem{$ID}\">"; if ($prevID) { echo "<a href=\"javascript:void()\" onClick=\"ajax('type=memmove&id1={$prevID}&id2={$ID}', 'memlist', false)\" style=\"text-decoration: none;\">↑</a>"; } else { echo "↑"; } if ($nextID) { echo "<a href=\"javascript:void()\" onClick=\"ajax('type=memmove&id1={$ID}&id2={$nextID}', 'memlist', false)\" style=\"text-decoration: none;\">↓</a>"; } else { echo "↓"; } echo " "; formatMember($rowArray[$j]); echo "</li>\n"; $prevID = $ID; } $result = mysql_query("SELECT * FROM " . $db_prefix . "members WHERE position='' ORDER BY lastName", $con); while ($row = mysql_fetch_array($result)) { echo "<li id=\"mem" . $row['id'] . "\">"; formatMember($row); echo "</li>\n"; } }