Guest User

Untitled

a guest
Jun 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. $sql = "SELECT voting_user.*, voting_user_answer.*, voting_answeren.* FROM
  2. voting_user, voting_user_answer, voting_answeren WHERE
  3. voting_user_answer.thema_id = $thema_id AND voting_user.user_id =
  4. voting_user_answer.user_id AND voting_answeren.answer_id =
  5. voting_user_answer.answer_id";
  6.  
  7. $i=0;
  8. echo "<table border=1>";
  9. echo "<tr><th>answer-ID</th><th>answer</th><th>user</th>";
  10. foreach ($pdo->query($sql) as $row) {
  11.  
  12.  
  13. echo "<tr><td>".$row["answer_id"]."</td>
  14. <td>".$row["answer_option"]."</td><td>".$row["user_name"]."
  15. </td></tr>";
  16. $tableRows[$i]=array("answer_option"=>$row["answer_option"],
  17. "user_name"=>$row["user_name"], "cross"=>"x");
  18. $namen[$i]=$row["user_name"];
  19. $answer = Array
  20. (
  21. "answer_option" => $row["answer_option"]
  22. , "test2" => "x"
  23. );
  24.  
  25.  
  26. $i++;
  27. $counter=$i-1;
  28. }
  29. echo "</table>";
  30.  
  31.  
  32. $resultMatrix = array();
  33.  
  34. foreach($tableRows as $resulting) {
  35. $from = $resulting['answer_option'];
  36. $to = $resulting['user_name'];
  37. $cross = $resulting['cross'];
  38.  
  39. $resultMatrix[$from][$to] = $cross;
  40. }
  41.  
  42. echo '<table border="1">';
  43. echo '<tr>';
  44. echo '<th>', '#', '</th>';
  45.  
  46.  
  47. foreach($namen as $user_name) {
  48. echo '<th>', $namen[$i] ,'</th>';
  49. }
  50. echo '</tr>';
  51.  
  52. foreach(array_keys($resultMatrix) as $answer_option) {
  53. echo '<tr>';
  54. echo '<td>', $answer_option, '</td>';
  55. foreach(array_keys($resultMatrix[$answer_option]) as $user_name) {
  56. echo '<td>', $resultMatrix[$answer_option][$user_name], '</td>';
  57. }
  58.  
  59. echo '</tr>';
  60. }
  61. echo '</table>';
Add Comment
Please, Sign In to add comment