Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "db-unity/db.php";
- $specialty = $_POST['specialty'];
- //$specialty = "Информатика"; // Example
- $users = R::findAll("users");
- $array = [];
- $score = [];
- $j = 0;
- foreach ($users as $user) {
- if($user->specialty_1 == $specialty) {
- $array[$j] = $user;
- $score[$j] = 1;
- $j+=1;
- }
- else if ($user->specialty_2 == $specialty) {
- $array[$j] = $user;
- $score[$j] = 2;
- $j+=1;
- }
- else if ($user->specialty_3 == $specialty) {
- $array[$j] = $user;
- $score[$j] = 3;
- $j+=1;
- }
- }
- $output = "<h3>" . $specialty . "</h3><br>";
- $output .= " <table>
- <thead>
- <tr>
- <th>Фамилия</th>
- <th>Имя</th>
- <th>Отчество</th>
- <th>Рейтинговый балл</th>
- <th>Приоритет</th>
- </tr>
- </thead>
- <tbody>";
- $rightArray = [];
- for ($i = 0; $i < $j; $i += 1) {
- $zno_score = "";
- $priority = "";
- if($score[$i] == 1)
- $zno_score .= $array[$i]->zno_competition_score_1;
- else if($score[$i] == 2)
- $zno_score .= $array[$i]->zno_competition_score_2;
- else if($score[$i] == 3)
- $zno_score .= $array[$i]->zno_competition_score_3;
- if($score[$i] == 1)
- $priority .= $array[$i]->priority_1;
- else if($score[$i] == 2)
- $priority .= $array[$i]->priority_2;
- else if($score[$i] == 3)
- $priority .= $array[$i]->priority_3;
- $rightArray[$i] = array(
- 'surname' => $array[$i]->surname,
- 'name' => $array[$i]->name,
- 'middlename' => $array[$i]->middlename,
- 'zno_score' => $zno_score,
- 'priority' => $priority
- );
- }
- for ($i=0; $i < count($rightArray); $i++) {
- $sortkey[$i]=$rightArray[$i]['zno_score'];
- }
- arsort($sortkey); // по возрастанию, arsort($sortkey) - по убыванию
- foreach ($sortkey as $key => $key) {
- $sorted[]=$rightArray[$key];
- }
- for ($i = 0; $i < $j; $i += 1) {
- $output .=
- "<tr>
- <td>" . $sorted[$i]['surname'] . "</td>
- <td>" . $sorted[$i]['name'] . "</td>
- <td>" . $sorted[$i]['middlename'] . "</td>
- <td>" . $sorted[$i]['zno_score']. "</td>
- <td>" . $sorted[$i]['priority'] . "</td>
- </tr>";
- }
- $output .= "</tbody>
- </table>";
- echo $output;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement