<?php
global $dbc;

$result = mysqli_query($dbc, "SELECT * from tblUsers where ynDeleted = 0") or die(mysqli_error($dbc));
$news .= '<table id="imagesTable">
<tr>
<th>Full Name</th>
<th>User Name</th>
<th>Security Level</th>
<th>Last Login</th>
<th colspan="2">Options</th></tr>';

while ($row = mysqli_fetch_array($result)) 
{
	$intUserID = $row['intUserID'];
	$strFirstName = $row['strFirstName'];
	$strLastName = $row['strLastName'];
	$intSecurityLevel = $row['intSecurityLevel'];
	$lastLogin = $row['dateLastLogin'];
	$username = $row['strUsername'];

	if ($intSecurityLevel == 25)
	{
		$securityLevel = "User";
	}
	if ($intSecurityLevel == 50)
	{
		$securityLevel = "Admin";
	}

	$news .= '<tr><td>'.$strLastName . ', ' . $strFirstName.'</td>';
	$news .= '<td>'.$username.'</td>';
	$news .= '<td>'. $securityLevel.'</td>';
	if ($lastLogin == "" || strcmp($lastLogin, '0000-00-00 00:00:00') == 0)
	{
		$news .= '<td>Hasn\'t logged in</td>';
	}
	else
	{
		$news .= '<td>'.$lastLogin.'</td>';			
	}
	$news .= '<td><a class="orangeText" href="edit-user.php?i='.$intUserID.'" title="Edit '.$strFirstName . ' ' . $strLastName.'\'s account."><button class="edit fg-button-option">
			<span class="ui-icon ui-icon-pencil"></span>
			</button></a></td>';
	$news .= '<td><a onclick="return confirm(\'Are you sure you want to remove this user?\');" class="orangeText" href="delete-user.php?i='.$intUserID.'" title="Delete '.$strFirstName . ' ' .$strLastName.'\'s account."><button class="delete fg-button-option">
		<span class="ui-icon ui-icon-trash"></span>
		</button></a></td></tr>';
}
$news .= '</table>';

mysqli_free_result($result);

?>