Forum Moderators: coopster
//approve any users before reloading the page
if ($user_id && $approve) {
$approval_query = "UPDATE users SET approved=1 WHERE user_id = '$user_id'";
$approval_result = @mysql_query($approval_query) OR DIE ('could not update: ' . mysql_error() );
}
//select unapproved rows from the users table
$users_select = 'SELECT * FROM users WHERE approved = 0' ;
$users_result = @mysql_query($users_select) or die(mysql_error()) ;
$approve = '<a href="{approve.php?user_id=$user_id&approve=yes">approve</a>';
if (mysql_num_rows($users_result) >0) {
//give the fields names
while ($users_row = mysql_fetch_array($users_result)) {
$user_id = $users_row['user_id'] ;
$user_name = $users_row['user_name'] ;
$admin_email = $users_row['admin_email'] ;
$contact_name = $users_row['contact_name'];
$inq_email_1 = $users_row['inq_email_1'];
$inq_email_2 = $users_row['inq_email_2'];
$phone_num = $users_row['phone_num'];
$fax_num = $users_row['fax_num'];
$street_addr = $users_row['street_addr'];
$city = $users_row['city'];
$state = $users_row['state'];
$zip = $users_row['zip'];
$country = $users_row['country'];
$date_registered = $users_row['date_registered'];
$approve = '<a href="approve.php?user_id='.$user_id.'&approve=1">approve</a>';
//build the display block
$display_users .= <<<diplayusers
<tr>
<td>$user_id</td>
<td>$user_name</td>
<td>$admin_email</td>
<td>$contact_name</td>
<td>$inq_email_1</td>
<td>$inq_email_2</td>
<td>$phone_num</td>
<td>$fax_num</td>
<td> $street_addr, $city, $state, $zip, $country </td>
<td>$date_registered</td>
<td>$approve</td>
</tr>
diplayusers;
} // close the while loop
} else {
$display_users = "There are no users to approve." ;
} // close the else statement
?>
<h3>Users awaiting approval:</h3>
<table width="95%" border="1">
<tr>
<td width="4%"><strong>User ID</strong></td>
<td width="15%"><strong>User Name</strong></td>
<td width="8%"><strong>Admin Email</strong></td>
<td width="8%"><strong>Contact Name</strong></td>
<td width="8%"><strong>Inquiry Email 1</strong></td>
<td width="8%"><strong>Inquiry Email 2</strong></td>
<td width="8%"><strong>Phone</strong></td>
<td width="8%"><strong>Fax</strong></td>
<td width="18%"><strong>Address</strong></td>
<td width="7%"><strong>Date Registered</strong></td>
<td width="7%"><strong>Approve</strong></td>
</tr>
<? echo "$display_users";?>
</table>