
Originally Posted by
thetestingsite
Great, let us know if you need any more help on this.
Hiya! I tried to add an 'Edit' link, but now it's not displaying anything... Basically the 'Edit ' link when clicked on is meant to change the member from 'MemberStatus' 'A' to 'D'... any ideas?
PHP Code:
<?php
$cat = $_GET['cat'];
/* connect to the mysql database and use a query to get the members info */
include 'library/config.php';
include 'library/opendb.php';
//navigation
include("nav.php");
//approved
$a = mysql_query("SELECT * FROM `tblmembers` WHERE `MemberApproved`='A'");
$aCount = mysql_num_rows($a);
//deleted
$d = mysql_query("SELECT * FROM `tblmembers` WHERE `MemberApproved`='D'");
$dCount = mysql_num_rows($d);
//on hold
$h = mysql_query("SELECT * FROM `tblmembers` WHERE `MemberApproved`='H'");
$hCount = mysql_num_rows($h);
//pending
$p = mysql_query("SELECT * FROM `tblmembers` WHERE `MemberApproved`='P'");
$pCount = mysql_num_rows($p);
//not sure
$n = mysql_query("SELECT * FROM `tblmembers` WHERE `MemberApproved`='N'");
$nCount = mysql_num_rows($n);
//rejected
$r = mysql_query("SELECT * FROM `tblmembers` WHERE `MemberApproved`='R'");
$rCount = mysql_num_rows($r);
if ($cat == "a") {
$field = "Approved";
$theCount = $aCount;
}
elseif ($cat == "d") {
$field = "Deleted";
$theCount = $hCount;
}
elseif ($cat == "h") {
$field = "On Hold";
$theCount = $hCount;
}
elseif ($cat == "p") {
$field = "Pending";
$theCount = $pCount;
}
elseif ($cat == "n") {
$field = "Not Sure";
$theCount = $nCount;
}
elseif ($cat == "r") {
$field = "Rejected";
$theCount = $rCount;
}
echo 'There are '.$theCount.' members that are '.$field;
if (isset($_GET['del']) AND $_GET['del'] <> "") {
/* construct and run our "deactivate" query */
$query = "UPDATE tblmembers SET MemberAPP = 'D' WHERE `MemberID`='" . $_GET['del'] ."' LIMIT 1";
$result = mysql_query ($query);
}
/* set the allowed order by columns */
$default_sort = 'LastName';
$allowed_order = array ('JoinDate', 'FirstName','LastName', 'loginDateTime');
/* if order is not set, or it is not in the allowed
* list, then set it to a default value. Otherwise,
* set it to what was passed in. */
if (!isset($_GET['order']) OR !in_array ($_GET['order'], $allowed_order)) {
$order = $default_sort;
} else {
$order = $_GET['order'];
}
/* construct and run our query */
$query = "SELECT * FROM tblmembers WHERE `MemberApproved`='$cat' ORDER BY $order";
$result = mysql_query ($query);
/* make sure data was retrieved */
if (mysql_num_rows($result)) {
echo "No data to display!";
} else {
/* now grab the first row and start the table */
$row = mysql_fetch_assoc ($result);
echo "<table border=1>\n";
$table_init = true;
echo "<TR>\n";
while ($row = mysql_fetch_assoc ($result)) {
if ($table_init) {
$table_init = false;
/* check if the heading is in our allowed_order array. If it is, hyperlink it so that we can order by this column */
echo "<tr>\n";
foreach ($row as $heading => $column) {
echo "<td>";
if (in_array ($heading, $allowed_order)) {
echo "<a href=\"{$_SERVER['PHP_SELF']}?order=$heading&cat=$cat\"><b>$heading</b></a>";
} else {
echo $heading;
}
echo "</td>\n";
}
echo "<td>Del?</td>";
echo "</tr>\n";
} else {
echo "<tr>\n";
foreach ($row as $heading => $column) {
echo "<td>$column</td>\n";
}
echo "<a href=\"{$_SERVER['PHP_SELF']}?del=" . $row['MemberID'] . "&order=$heading&cat=$cat\">Delete</a>";
echo "</tr>\n";
}
}
echo "</table>\n";
}
?>
Bookmarks