Advertisement
RobinJ1995

Untitled

Dec 3rd, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2. $dblink = new PDO
  3. (
  4.     'mysql:host=localhost;dbname=robinjw48_verveeltzich', 'robinjw48_verveeltzich', 'ikverveelme'
  5. );
  6. $dblink->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  7.  
  8. $query = $dblink->prepare('SELECT name, success, challenge FROM pogingen WHERE success>0');
  9. $query->execute();
  10. $temp = $query->fetchAll();
  11. echo '  <h2 id="scorelijst">Scorelijst</h2>
  12.     <table border="1">
  13.         <tr>
  14.             <th>Naam</th>
  15.             <th>Challenges</th>
  16.             <th>Punten</th>
  17.         </tr>';
  18. $punten = array();
  19. $challengesdone = array();
  20. $namen = array();
  21. $strchallengesdone = array();
  22. foreach ($temp as $row)
  23. {
  24.     if (!(in_array ($row['name'], $namen)))
  25.     {
  26.         $namen[] = $row['name'];
  27.     }
  28.     if (!(@in_array ($row['challenge'], $challengesdone[$row['name']])))
  29.     {
  30.         $punten[$row['name']] += $row['success'];
  31.         $challengesdone[$row['name']][] = $row['challenge'];
  32.     }
  33. }
  34. foreach ($namen as $naam)
  35. {
  36.     foreach ($challengesdone[$naam] as $temp)
  37.     {
  38.         $strchallengesdone[$naam] .= $temp . ' ';
  39.     }  
  40. }
  41. foreach ($namen as $naam)
  42. {
  43.     echo '      <tr>
  44.             <td>' . htmlentities($naam) . '</td>
  45.             <td>' . htmlentities($strchallengesdone[$naam]) . '</td>
  46.             <td>' . htmlentities($punten[$naam]) . '</td>
  47.         <tr>';
  48. }
  49. echo '  </table>';
  50. ?>
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement