I have added following PHP code in my Joomla webapplication. This will create a table of all users from a User Group.
How Can I make this table sortable?
Is there some Joomla/PHP code or plugin to order this list by Name? Can I add a parameter to sort this by any column?
<?php
$teachers = JAccess::getUsersByGroup(10); //change number in the brackets
echo "<table class=\"table table-striped\">";
echo "<thead>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Street</th>";
echo "<th>Zip</th>";
echo "<th>City</th>";
echo "<th>Phone</th>";
echo "<th>Email</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
foreach($teachers as $user_id) {
$user = JFactory::getUser($user_id);
$profile = JUserHelper::getProfile($user->id);
echo "<tr>";
echo "<td>".$user->name."</td>";
echo "<td>".$profile->profile['address1']."</td>";
echo "<td>".$profile->profile['postal_code']."</td>";
echo "<td>".$profile->profile['city']."</td>";
echo "<td>".$profile->profile['phone']."</td>";
echo "<td>".$user->email."</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>