Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sql = "SELECT voting_user.*, voting_user_answer.*, voting_answeren.* FROM
- voting_user, voting_user_answer, voting_answeren WHERE
- voting_user_answer.thema_id = $thema_id AND voting_user.user_id =
- voting_user_answer.user_id AND voting_answeren.answer_id =
- voting_user_answer.answer_id";
- $i=0;
- echo "<table border=1>";
- echo "<tr><th>answer-ID</th><th>answer</th><th>user</th>";
- foreach ($pdo->query($sql) as $row) {
- echo "<tr><td>".$row["answer_id"]."</td>
- <td>".$row["answer_option"]."</td><td>".$row["user_name"]."
- </td></tr>";
- $tableRows[$i]=array("answer_option"=>$row["answer_option"],
- "user_name"=>$row["user_name"], "cross"=>"x");
- $namen[$i]=$row["user_name"];
- $answer = Array
- (
- "answer_option" => $row["answer_option"]
- , "test2" => "x"
- );
- $i++;
- $counter=$i-1;
- }
- echo "</table>";
- $resultMatrix = array();
- foreach($tableRows as $resulting) {
- $from = $resulting['answer_option'];
- $to = $resulting['user_name'];
- $cross = $resulting['cross'];
- $resultMatrix[$from][$to] = $cross;
- }
- echo '<table border="1">';
- echo '<tr>';
- echo '<th>', '#', '</th>';
- foreach($namen as $user_name) {
- echo '<th>', $namen[$i] ,'</th>';
- }
- echo '</tr>';
- foreach(array_keys($resultMatrix) as $answer_option) {
- echo '<tr>';
- echo '<td>', $answer_option, '</td>';
- foreach(array_keys($resultMatrix[$answer_option]) as $user_name) {
- echo '<td>', $resultMatrix[$answer_option][$user_name], '</td>';
- }
- echo '</tr>';
- }
- echo '</table>';
Add Comment
Please, Sign In to add comment