diff --git a/webui/group-attribute-delete.php b/webui/group-attribute-delete.php
index 16fbfab2edc577eda2d9849a29523bce48863586..6a6eab674259f05a3306c0cefc08aca73ce7ac4b 100644
--- a/webui/group-attribute-delete.php
+++ b/webui/group-attribute-delete.php
@@ -88,7 +88,7 @@ if ($_POST['frmaction'] == "delete") {
 		# Warn
 		} else {
 ?>
-		<div class="warning">Delete attribute aborted</div>
+			<div class="warning">Delete attribute aborted</div>
 <?php
 		}
 ?>
diff --git a/webui/group-users.php b/webui/group-users.php
index b035bc2df027960ee22a86aabd508428dc0d5a7f..a7d66568b2b037c1e2e8d1c56c12db00bff9ed67 100644
--- a/webui/group-users.php
+++ b/webui/group-users.php
@@ -37,14 +37,17 @@ printHeader(array(
 if (isset($_POST['group_id'])) {
 
 ?>
+
 	<p class="pageheader">Group Members</p>
 
 <?php
 
+	# Get group name
 	$group_stmt = $db->prepare("SELECT Name FROM ${DB_TABLE_PREFIX}groups WHERE ID = ?");
 	$group_stmt->execute(array($_POST['group_id']));
 	$row = $group_stmt->fetchObject();
 	$group_stmt->closeCursor();
+
 ?>
 
 		<table class="results" style="width: 75%;">
@@ -53,8 +56,10 @@ if (isset($_POST['group_id'])) {
 				<td class="textcenter">Member</td>
 				<td class="textcenter">Disabled</td>
 			</tr>
+
 <?php
 
+			# Get list of members belonging to this group
 			$stmt = $db->prepare("SELECT UserID FROM ${DB_TABLE_PREFIX}users_to_groups WHERE GroupID = ?");
 			$res = $stmt->execute(array($_REQUEST['group_id']));
 
@@ -72,37 +77,52 @@ if (isset($_POST['group_id'])) {
 
 				# List users
 				while ($row = $res->fetchObject()) {
+
 ?>
+
 					<tr class="resultsitem">
 						<td><?php echo $row->id ?></td>
 						<td><?php echo $row->username ?></td>
 						<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
 					</tr>
+
 <?php
+
 				}
 				$res->closeCursor();
 			}
 			$stmt->closeCursor();
+
+			# Did we get any results?
 			if ($rownums <= 0) {
+
 ?>
+
 				<p />
 				<tr>
 					<td colspan="3" class="textcenter">Group has no users</td>
 				</tr>
+
 <?php
+
 			}
 			unset($rownums);
+
 ?>
+
 		</table>
-	</form>
+
 <?php
+
 } else {
+
 ?>
+
 	<div class="warning">Invalid invocation</div>
-<?php
-}
 
+<?php
 
+}
 printFooter();
 
 
diff --git a/webui/user-attributes.php b/webui/user-attributes.php
index 88af182b93bce8cdd04dc8f1ca0a4c20da4a38bf..9cbfb8c8fbd666c47f56a76380d32eb7e6d27d64 100644
--- a/webui/user-attributes.php
+++ b/webui/user-attributes.php
@@ -34,6 +34,7 @@ printHeader(array(
 ));
 
 ?>
+
 <p class="pageheader">Attribute List</p>
 
 <form id="main_form" action="user-attributes.php" method="post">
@@ -63,7 +64,7 @@ printHeader(array(
 		</select> 
 	</div>
 
-<p />
+	<p />
 
 	<table class="results" style="width: 75%;">
 		<tr class="resultstitle">
@@ -73,51 +74,67 @@ printHeader(array(
 			<td class="textcenter">Value</td>
 			<td class="textcenter">Disabled</td>
 		</tr>
+
+<?php
+
+		$_SESSION['attr_user_id'] = $_POST['user_id']; 
+		if (isset($_POST['user_id'])) {
+
+			$temp = $_SESSION['attr_user_id'];
+			$sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}user_attributes WHERE UserID = $temp ORDER BY ID";
+			$res = $db->query($sql);
+
+			$rownums = 0;
+			while ($row = $res->fetchObject()) {
+				if ($row->id != NULL) {
+					$rownums = $rownums + 1;
+				} else {
+					$rownums = $rownums - 1;
+				}
+
+?>
+				<tr class="resultsitem">
+					<td><input type="radio" name="attr_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td>
+					<td><?php echo $row->name ?></td>
+					<td><?php echo $row->operator ?></td>
+					<td><?php echo $row->value ?></td>
+					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+				</tr>
+
 <?php
-	$_SESSION['attr_user_id'] = $_POST['user_id']; 
-	if (isset($_POST['user_id'])) {
-
-		$temp = $_SESSION['attr_user_id'];
-		$sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}user_attributes WHERE UserID = $temp ORDER BY ID";
-		$res = $db->query($sql);
-
-		$rownums = 0;
-		while ($row = $res->fetchObject()) {
-			if ($row->id != NULL) {
-				$rownums = $rownums + 1;
-			} else {
-				$rownums = $rownums - 1;
+
 			}
+			$res->closeCursor();
+			if ($rownums <= 0) {
+
 ?>
-			<tr class="resultsitem">
-				<td><input type="radio" name="attr_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td>
-				<td><?php echo $row->name ?></td>
-				<td><?php echo $row->operator ?></td>
-				<td><?php echo $row->value ?></td>
-				<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
-			</tr>
+
+				<p />
+				<tr>
+					<td colspan="5" class="textcenter">Group attribute list is empty</td>
+				</tr>
+
 <?php
-		}
-		$res->closeCursor();
-		if ($rownums <= 0) {
+
+			}
+			unset($rownums);
+		} else {
+
 ?>
-			<p />
-			<tr>
-				<td colspan="5" class="textcenter">Group attribute list is empty</td>
+
+			<tr class="resultitem">
+				<td colspan="5" class="textcenter">No User ID selected</td>
 			</tr>
+
 <?php
+
 		}
-		unset($rownums);
-	} else {
-?>
-		<tr class="resultitem">
-			<td colspan="5" class="textcenter">No User ID selected</td>
-		</tr>
-<?php
-	}
+
 ?>
+
 	</table>
 </form>
+
 <?php
 
 printFooter();
diff --git a/webui/user-groups-add.php b/webui/user-groups-add.php
index f13b6b977f7d600cb8b9f42964f8954bc10ffcf8..56c034154e793b503d34083e09f7362a212f8748 100644
--- a/webui/user-groups-add.php
+++ b/webui/user-groups-add.php
@@ -15,85 +15,101 @@
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-session_start();
 
 
+session_start();
+
 
 include_once("includes/header.php");
 include_once("includes/footer.php");
 include_once("includes/db.php");
 
 
-
 $db = connect_db();
 
 
 printHeader(array(
 ));
+
+
 if (isset($_SESSION['groups_user_id'])) {
 	if ($_POST['frmaction'] == "add") {
+
 ?>
 		<p class="pageheader">Available Groups</p>
 
 		<form id="main_form" action="user-groups-add.php" method="post">
+			<div class="textcenter">
+				<input type="hidden" name="frmaction" value="add2" />
+				<table class="entry">
+					<tr>
+						<td class="entrytitle">Comment</td>
+						<td class="entrytitle">Disabled</td>
+					</tr>
+					<tr>
+						<td><input type="text" name="users_to_groups_comment" /></td>
+						<td>
+							<select name="users_group_disabled">
+								<option value="0">No</option>
+								<option value="1">Yes</option>
+							</select>
+						</td>
+						<td>
+							<input type="submit" value="Submit" />
+						</td>
+					</tr>
+				</table>
+			</div>
 
-		<div class="textcenter">
-			<input type="hidden" name="frmaction" value="add2" />
-			<table class="entry">
-				<tr>
-					<td class="entrytitle">Comment</td>
-					<td class="entrytitle">Disabled</td>
-				</tr>
-				<tr>
-					<td><input type="text" name="users_to_groups_comment" /></td>
-					<td>
-						<select name="users_group_disabled">
-							<option value="0">No</option>
-							<option value="1">Yes</option>
-						</select>
-					</td>
-					<td>
-						<input type="submit" value="Submit" />
-					</td>
+			<p />
+
+			<table class="results" style="width: 75%;">
+				<tr class="resultstitle">
+					<td class="textcenter">ID</td>
+					<td class="textcenter">Name</td>
+					<td class="textcenter">Priority</td>
+					<td class="textcenter">Disabled</td>
+					<td class="textcenter">Comment</td>
 				</tr>
-			</table>
-		</div>
-
-		<p />
-
-		<table class="results" style="width: 75%;">
-			<tr class="resultstitle">
-				<td class="textcenter">ID</td>
-				<td class="textcenter">Name</td>
-				<td class="textcenter">Priority</td>
-				<td class="textcenter">Disabled</td>
-				<td class="textcenter">Comment</td>
-			</tr>
+
 <?php
-			# List current available groups
-			$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM ${DB_TABLE_PREFIX}groups ORDER BY ID";
-			$res = $db->query($sql);
 
-			while ($row = $res->fetchObject()) {
+				# List current available groups
+				$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM ${DB_TABLE_PREFIX}groups ORDER BY ID";
+				$res = $db->query($sql);
+
+				while ($row = $res->fetchObject()) {
+
 ?>
-				<tr class="resultsitem">
-					<td><input type="radio" name="group_id" value="<?php echo $row->id ?>" /></td>
-					<td><?php echo $row->name ?></td>
-					<td><?php echo $row->priority ?></td>
-					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
-					<td><?php echo $row->comment ?></td>
-				</tr>
+
+					<tr class="resultsitem">
+						<td><input type="radio" name="group_id" value="<?php echo $row->id ?>" /></td>
+						<td><?php echo $row->name ?></td>
+						<td><?php echo $row->priority ?></td>
+						<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+						<td><?php echo $row->comment ?></td>
+					</tr>
+
 <?php
-			}
-			$res->closeCursor();
+
+				}
+				$res->closeCursor();
+
 ?>
-		</table>
-	</form>
+
+			</table>
+		</form>
+
 <?php
+
 	} elseif ($_POST['frmaction'] == "add2") {
+
 ?>
+
 		<p class="pageheader">Group assignment results</p>
+
 <?php
+
 		if (isset($_POST['group_id']) && !empty($_POST['users_to_groups_comment'])) {
 			$stmt = $db->prepare("INSERT INTO ${DB_TABLE_PREFIX}users_to_groups (UserID,GroupID,Comment,Disabled) VALUES (?,?,?,?)");
 			# Which user am I working with?
@@ -105,27 +121,45 @@ if (isset($_SESSION['groups_user_id'])) {
 						$_POST['users_group_comment'],
 						$_POST['users_group_disabled'],
 						));
+
 			if ($res) {
+
 ?>
+
 				<div class="notice">Group assignment successful</div>
+
 <?php
+
 			} else {
+
 ?>
+
 				<div class="warning">Failed to assign group to user</div>
 				<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
+
 <?php
+
 			}
 		} else {
+
 ?>
+
 			<div class="warning">One or more values not set</div>
-<?php 
+
+<?php
+
 		}
 	}
 } else {
+
 ?>
+
 	<div class="warning">No user id received</div>
+
 <?php
+
 }
+
 printFooter();
 
 # vim: ts=4
diff --git a/webui/user-groups-delete.php b/webui/user-groups-delete.php
index f6ac383506204f72508bb376f52885aef9cdee1a..004e15c809341b19ab3f05cfb29391cae90bf20b 100644
--- a/webui/user-groups-delete.php
+++ b/webui/user-groups-delete.php
@@ -88,7 +88,7 @@ if ($_POST['frmaction'] == "delete") {
 		# Warn
 		} else {
 ?>
-		<div class="warning">Remove Group Assignment aborted</div>
+			<div class="warning">Remove Group Assignment aborted</div>
 <?php
 		}
 ?>
diff --git a/webui/user-groups.php b/webui/user-groups.php
index 1483d08473fc8bf1ce7ed4f377d3298c23748229..74a94750e63e2c528df7a9c01baaf336496fff9a 100644
--- a/webui/user-groups.php
+++ b/webui/user-groups.php
@@ -19,6 +19,7 @@
 
 session_start();
 
+
 include_once("includes/header.php");
 include_once("includes/footer.php");
 include_once("includes/db.php");
@@ -33,7 +34,9 @@ printHeader(array(
 		),
 ));
 
+
 ?>
+
 <p class="pageheader">Groups List</p>
 
 <form id="main_form" action="user-groups.php" method="post">
@@ -69,54 +72,70 @@ printHeader(array(
 			<td class="textcenter">Disabled</td>
 			<td class="textcenter">Comment</td>
 		</tr>
+
 <?php
-	if (isset($_POST['user_id'])) {
-		$sql = "SELECT GroupID FROM ${DB_TABLE_PREFIX}users_to_groups WHERE UserID = ".$_POST['user_id'];
-		$res = $db->query($sql);
-
-		$rownums = 0;
-		while ($row = $res->fetchObject()) {
-			if ($row->groupid != NULL) {
-				$rownums = $rownums + 1;
-			} else {
-				$rownums = $rownums - 1;
+
+		if (isset($_POST['user_id'])) {
+			$sql = "SELECT GroupID FROM ${DB_TABLE_PREFIX}users_to_groups WHERE UserID = ".$_POST['user_id'];
+			$res = $db->query($sql);
+
+			$rownums = 0;
+			while ($row = $res->fetchObject()) {
+				if ($row->groupid != NULL) {
+					$rownums = $rownums + 1;
+				} else {
+					$rownums = $rownums - 1;
+				}
+				$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM ${DB_TABLE_PREFIX}groups WHERE ID = ".$row->groupid;
+				$result = $db->query($sql);
+
+				while ($row = $result->fetchObject()) {
+
+?>
+
+					<tr class="resultsitem">
+						<td><input type="radio" name="group_id" value="<?php echo $row->id ?>"/></td>
+						<td><?php echo $row->name ?></td>
+						<td><?php echo $row->priority ?></td>
+						<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
+						<td><?php echo $row->comment ?></td>
+					</tr>
+
+<?php
+
+				}
+				$result->closeCursor();
 			}
-			$sql = "SELECT ID, Name, Priority, Disabled, Comment FROM ${DB_TABLE_PREFIX}groups WHERE ID = ".$row->groupid;
-			$result = $db->query($sql);
 
-			while ($row = $result->fetchObject()) {
+			$res->closeCursor();
+			if ($rownums <= 0) {
+
 ?>
-				<tr class="resultsitem">
-					<td><input type="radio" name="group_id" value="<?php echo $row->id ?>"/></td>
-					<td><?php echo $row->name ?></td>
-					<td><?php echo $row->priority ?></td>
-					<td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td>
-					<td><?php echo $row->comment ?></td>
+
+				<p />
+				<tr>
+					<td colspan="5" class="textcenter">User doesn't belong to any groups</td>
 				</tr>
+
 <?php
+
 			}
-		$result->closeCursor();
-		}
-		$res->closeCursor();
-		if ($rownums <= 0) {
+			unset($rownums);
+		} else {
+
 ?>
-			<p />
-			<tr>
-				<td colspan="5" class="textcenter">User doesn't belong to any groups</td>
-			</tr>
+
+			<div class="warning">Invocation error, no user ID selected</div>
+
 <?php
+
 		}
-		unset($rownums);
+
 ?>
+
 	</table>
 </form>
-<?php
-	} else {
-?>
-		<div class="warning">Invocation error, no user ID selected</div>
-<?php
-	}
-?>
+
 <?php
 
 $_SESSION['groups_user_id'] = $_POST['user_id'];
diff --git a/webui/user-logs.php b/webui/user-logs.php
index c77ad3b1c79d18d989c877f88988cc4dac04a653..e2a1c2b5e4301de32901fa5741fd88afdc017e57 100644
--- a/webui/user-logs.php
+++ b/webui/user-logs.php
@@ -35,186 +35,194 @@ printHeader(array(
 
 
 ?>
+
 <p class="pageheader">User Log</p>
+
 <?php
+
 if (isset($_POST['user_id'])) {
 
-		# Which user in the accounting table should we look for?
-		$stmt = $db->prepare("SELECT Username FROM ${DB_TABLE_PREFIX}users WHERE ID = ?");
-		$stmt->execute(array($_POST['user_id']));
-		$row = $stmt->fetchObject();
-		$stmt->closeCursor();
-		$getuser = $row->username;
+	# Which user in the accounting table should we look for?
+	$stmt = $db->prepare("SELECT Username FROM ${DB_TABLE_PREFIX}users WHERE ID = ?");
+	$stmt->execute(array($_POST['user_id']));
+	$row = $stmt->fetchObject();
+	$stmt->closeCursor();
+	$getuser = $row->username;
 
 ?>
-		<form id="main_form" action="user-logs.php" method="post">
-			<!-- User input from and to dates -->
-			<div>
-				<table>
-					<tr>
-						<td>From (yyyy-mm-dd)</td>
-					</tr>
-					<tr>
-						<td><input type="text" name="date_from" /></td>
-					</tr>
-					<tr>
-						<td>To (yyyy-mm-dd)</td>
-					</tr>
-					<tr>
-						<td><input type="text" name="date_to" /></td>
-					</tr>
-					<tr>
-						<input type="hidden" name="user_id" value=<?php echo $_POST['user_id']; ?> />
-						<td><input type="submit" value="Get results" /></td>
-					</tr>
-				</table>
-			</div>
-		</form>
-
-		<p />
-
-		<!-- Tables headings -->
-		<table class="results" style="width: 75%;">
-			<tr class="resultstitle">
-				<td class="textcenter">EventTimestamp</td>
-				<td class="textcenter">ServiceType</td>
-				<td class="textcenter">FramedProtocol</td>
-				<td class="textcenter">NASPort</td>
-				<td class="textcenter">NASPortType</td>
-				<td class="textcenter">CallingSationID</td>
-				<td class="textcenter">CalledStationID</td>
-				<td class="textcenter">NASPortID</td>
-				<td class="textcenter">AcctSessionID</td>
-				<td class="textcenter">FramedIPAddress</td>
-				<td class="textcenter">AcctAuthentic</td>
-				<td class="textcenter">NASIdentifier</td>
-				<td class="textcenter">NASIPAddress</td>
-				<td class="textcenter">AcctDelayTime</td>
-				<td class="textcenter">AcctSessionTime</td>
-				<td class="textcenter">Data-Input</td>
-				<td class="textcenter">Data-Output</td>
-				<td class="textcenter">AcctStatusType</td>
-				<td class="textcenter">AcctTerminateCause</td>
-			</tr>
+
+	<form id="main_form" action="user-logs.php" method="post">
+		<!-- User input from and to dates -->
+		<div>
+			<table>
+				<tr>
+					<td>From (yyyy-mm-dd)</td>
+				</tr>
+				<tr>
+					<td><input type="text" name="date_from" /></td>
+				</tr>
+				<tr>
+					<td>To (yyyy-mm-dd)</td>
+				</tr>
+				<tr>
+					<td><input type="text" name="date_to" /></td>
+				</tr>
+				<tr>
+					<input type="hidden" name="user_id" value=<?php echo $_POST['user_id']; ?> />
+					<td><input type="submit" value="Get results" /></td>
+				</tr>
+			</table>
+		</div>
+	</form>
+
+	<p />
+
+	<!-- Tables headings -->
+	<table class="results" style="width: 75%;">
+		<tr class="resultstitle">
+			<td class="textcenter">EventTimestamp</td>
+			<td class="textcenter">ServiceType</td>
+			<td class="textcenter">FramedProtocol</td>
+			<td class="textcenter">NASPort</td>
+			<td class="textcenter">NASPortType</td>
+			<td class="textcenter">CallingSationID</td>
+			<td class="textcenter">CalledStationID</td>
+			<td class="textcenter">NASPortID</td>
+			<td class="textcenter">AcctSessionID</td>
+			<td class="textcenter">FramedIPAddress</td>
+			<td class="textcenter">AcctAuthentic</td>
+			<td class="textcenter">NASIdentifier</td>
+			<td class="textcenter">NASIPAddress</td>
+			<td class="textcenter">AcctDelayTime</td>
+			<td class="textcenter">AcctSessionTime</td>
+			<td class="textcenter">Data-Input</td>
+			<td class="textcenter">Data-Output</td>
+			<td class="textcenter">AcctStatusType</td>
+			<td class="textcenter">AcctTerminateCause</td>
+		</tr>
+
 <?php
-			# Extra SQL
-			$extraSQL = "";
-			$extraSQLVals = array();
-			$limitSQL = "";
-
-			# Do we have a from date?, if so add it to our query
-			if (isset($_POST['date_from'])) {
-				$extraSQL .= " AND EventTimestamp >= ?";
-				array_push($extraSQLVals,$_POST['date_from']);
+
+		# Extra SQL
+		$extraSQL = "";
+		$extraSQLVals = array();
+		$limitSQL = "";
+
+		# Do we have a from date?, if so add it to our query
+		if (isset($_POST['date_from'])) {
+			$extraSQL .= " AND EventTimestamp >= ?";
+			array_push($extraSQLVals,$_POST['date_from']);
+		}
+		# Do we have a from date?, if so add it to our query
+		if (isset($_POST['date_to'])) {
+			$extraSQL .= " AND EventTimestamp <= ?";
+			array_push($extraSQLVals,$_POST['date_to']);
+		}
+
+		# Modify if we had a partial search or no search
+		if (count($extraSQLVals) < 2) {
+			$limitSQL = "LIMIT 50";
+		}
+
+		# Query to get all default data
+		$sql = "
+			SELECT
+					EventTimestamp, 
+					ServiceType,
+					FramedProtocol,
+					NASPort,
+					NASPortType, 
+					CallingStationID, 
+					CalledStationID, 
+					NASPortID, 
+					AcctSessionID, 
+					FramedIPAddress, 
+					AcctAuthentic, 
+					NASIdentifier, 
+					NASIPAddress, 
+					AcctDelayTime, 
+					AcctSessionTime, 
+					AcctInputOctets, 
+					AcctInputGigawords, 
+					AcctOutputOctets, 
+					AcctOutputGigawords, 
+					AcctStatusType, 
+					AcctTerminateCause 
+			FROM 
+					${DB_TABLE_PREFIX}accounting 
+			WHERE 
+					Username = '$getuser'
+					$extraSQL
+			ORDER BY
+					EventTimestamp
+			DESC
+				$limitSQL
+			";
+
+		$res = $db->prepare($sql);
+		$res->execute($extraSQLVals);
+
+		$totalInputData = 0;
+		$totalOutputData =0;
+		$totalSessionTime = 0;
+		$rownums = 0;
+
+		while ($row = $res->fetchObject()) {
+
+			if ($row->eventtimestamp != NULL) {
+				$rownums = $rownums + 1;
+			} else {
+				$rownums = $rownums - 1;
+			}
+
+			# Data usage
+			# ==========
+
+			# Input
+			$inputDataItem = 0;
+
+			if (!empty($row->acctinputoctets) && $row->acctinputoctets > 0) {
+				$inputDataItem = ($row->accinputoctets / 1024 / 1024);
 			}
-			# Do we have a from date?, if so add it to our query
-			if (isset($_POST['date_to'])) {
-				$extraSQL .= " AND EventTimestamp <= ?";
-				array_push($extraSQLVals,$_POST['date_to']);
+			if (!empty($row->acctinputgigawords) && $row->inputgigawords > 0) {
+				$inputDataItem = ($row->acctinputgigawords * 4096);
+			}
+			if ($inputDataItem != 0) {
+				$inputDataItemDisplay = ceil($inputDataItem * 100)/100;
+			} else {
+				$inputDataItemDisplay = 0;
+			}
+
+			$totalInputData = $totalInputData + $inputDataItem;
+
+			# Output
+			$outputDataItem = 0;
+
+			if (!empty($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
+				$outputDataItem = ($row->acctoutputoctets / 1024 / 1024);
+			}
+			if (!empty($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
+				$outputDataItem = ($row->acctoutputgigawords * 4096);
+			}
+			if ($outputDataItem != 0) {
+				$outputDataItem = ceil($outputDataItem * 100)/100;
+			} else {
+				$outputDataItem = 0;
 			}
 
-			# Modify if we had a partial search or no search
-			if (count($extraSQLVals) < 2) {
-				$limitSQL = "LIMIT 50";
+			$totalOutputData = $totalOutputData + $outputDataItem;
+
+			# Add up time
+			if (!empty($row->acctsessiontime) && $row->acctsessiontime > 0) {
+				$sessionTimeItem = $row->acctsessiontime / 60;
+				$sessionTimeItem = ceil($sessionTimeItem * 100)/100;
 			}
 
-				# Query to get all default data
-				$sql = "
-					SELECT
-							EventTimestamp, 
-							ServiceType,
-							FramedProtocol,
-							NASPort,
-							NASPortType, 
-							CallingStationID, 
-							CalledStationID, 
-							NASPortID, 
-							AcctSessionID, 
-							FramedIPAddress, 
-							AcctAuthentic, 
-							NASIdentifier, 
-							NASIPAddress, 
-							AcctDelayTime, 
-							AcctSessionTime, 
-							AcctInputOctets, 
-							AcctInputGigawords, 
-							AcctOutputOctets, 
-							AcctOutputGigawords, 
-							AcctStatusType, 
-							AcctTerminateCause 
-					FROM 
-							${DB_TABLE_PREFIX}accounting 
-					WHERE 
-							Username = '$getuser'
-							$extraSQL
-					ORDER BY
-							EventTimestamp
-					DESC
-						$limitSQL
-				";
-
-				$res = $db->prepare($sql);
-				$res->execute($extraSQLVals);
-
-				$totalInputData = 0;
-				$totalOutputData =0;
-				$totalSessionTime = 0;
-				$rownums = 0;
-				while ($row = $res->fetchObject()) {
-
-					if ($row->eventtimestamp != NULL) {
-						$rownums = $rownums + 1;
-					} else {
-						$rownums = $rownums - 1;
-					}
-
-					# Data usage
-					# ==========
-
-					# Input
-					$inputDataItem = 0;
-
-					if (!empty($row->acctinputoctets) && $row->acctinputoctets > 0) {
-						$inputDataItem = ($row->accinputoctets / 1024 / 1024);
-					}
-					if (!empty($row->acctinputgigawords) && $row->inputgigawords > 0) {
-						$inputDataItem = ($row->acctinputgigawords * 4096);
-					}
-					if ($inputDataItem != 0) {
-						$inputDataItemDisplay = ceil($inputDataItem * 100)/100;
-					} else {
-						$inputDataItemDisplay = 0;
-					}
-
-					$totalInputData = $totalInputData + $inputDataItem;
-
-					# Output
-					$outputDataItem = 0;
-
-					if (!empty($row->acctoutputoctets) && $row->acctoutputoctets > 0) {
-						$outputDataItem = ($row->acctoutputoctets / 1024 / 1024);
-					}
-					if (!empty($row->acctoutputgigawords) && $row->acctoutputgigawords > 0) {
-						$outputDataItem = ($row->acctoutputgigawords * 4096);
-					}
-					if ($outputDataItem != 0) {
-						$outputDataItem = ceil($outputDataItem * 100)/100;
-					} else {
-						$outputDataItem = 0;
-					}
-
-					$totalOutputData = $totalOutputData + $outputDataItem;
-
-					# Add up time
-					if (!empty($row->acctsessiontime) && $row->acctsessiontime > 0) {
-						$sessionTimeItem = $row->acctsessiontime / 60;
-						$sessionTimeItem = ceil($sessionTimeItem * 100)/100;
-					}
-
-					$totalSessionTime = $totalSessionTime + $sessionTimeItem;
-					$totalSessionTime = ceil($totalSessionTime * 100)/100;
+			$totalSessionTime = $totalSessionTime + $sessionTimeItem;
+			$totalSessionTime = ceil($totalSessionTime * 100)/100;
 
 ?>
+
 			<tr class="resultsitem">
 				<td class="textcenter"><?php echo $row->eventtimestamp; ?></td>
 				<td class="textcenter"><?php echo $row->servicetype; ?></td>
@@ -236,18 +244,26 @@ if (isset($_POST['user_id'])) {
 				<td class="textcenter"><?php echo $row->acctstatustype; ?></td>
 				<td class="textcenter"><?php echo strRadiusTermCode($row->acctterminatecause); ?></td>
 			</tr>
+
 <?php
-			}
-			$res->closeCursor();
 
-			if ($rownums <= 0) {
+		}
+		$res->closeCursor();
+
+		if ($rownums <= 0) {
+
 ?>
+
 			<tr>
 				<td colspan="23" class="textcenter">No logs found for user: <?php echo $getuser ?></td>
 			</tr>
+
 <?php
-			} else {
+
+		} else {
+
 ?>
+
 			<tr class="resultsitem">
 				<td class="textcenter"></td>
 				<td class="textcenter"></td>
@@ -269,21 +285,27 @@ if (isset($_POST['user_id'])) {
 				<td class="textcenter"></td>
 				<td class="textcenter"></td>
 			</tr>
+
+<?php
+
+		}
+?>
+		</table>
 <?php
-			}
 
 } else {
+
 ?>
-			<tr>
-				<td class="warning">No user ID selected</td>
-			</tr>
+	<div class="warning">No user selected</div>
 <?php
-}
 
+}
 
 ?>
-		</table>
+
+
 <?php
+
 printFooter();