Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $students = explode("\n", $_GET['students']);
- $id = 1;
- $studentsCollection = [];
- foreach ($students as $student) {
- if (empty($student)) continue;
- $student = explode(", ", $student);
- $studentsCollection[] = array(
- 'Id' => $id++,
- 'Username' => htmlspecialchars(($student[0])),
- 'Email' => htmlspecialchars(($student[1])),
- 'Type' => htmlspecialchars(($student[2])),
- 'Result' => htmlspecialchars(trim($student[3]))
- );
- }
- foreach ($studentsCollection as $key => $val) {
- $ids[$key] = $val['Id'];
- $column[$key] = $val[ucfirst($_GET['column'])];
- }
- $order = strtolower($_GET['order']) == 'descending' ? SORT_DESC : SORT_ASC;
- array_multisort($column, $order, $ids, $order, $studentsCollection);
- echo "<table><thead><tr><th>Id</th><th>Username</th><th>Email</th><th>Type</th><th>Result</th></tr></thead>";
- foreach ($studentsCollection as $row) {
- echo "<tr><td>{$row['Id']}</td><td>{$row['Username']}</td><td>{$row['Email']}</td><td>{$row['Type']}</td><td>{$row['Result']}</td></tr>";
- }
- echo "</table>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement