Advertisement
RobinJ1995

Untitled

Dec 2nd, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 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. $strpunten = array();
  23. foreach ($temp as $row)
  24. {
  25.     if (!(in_array ($row['name'], $namen)))
  26.     {
  27.         $namen[] = $row['name'];
  28.     }
  29.     if (!(@in_array ($row['challenge'], $challengesdone[$row['name']])))
  30.     {
  31.         $punten[$row['name']] += $row['success'];
  32.         $challengesdone[$row['name']][] = $row['challenge'];
  33.     }
  34. }
  35. foreach ($namen as $naam)
  36. {
  37.     foreach ($challengesdone[$naam] as $temp)
  38.     {
  39.         $strchallengesdone[$naam] .= $temp . ' ';
  40.     }  
  41. }
  42. foreach ($namen as $naam)
  43. {
  44.     echo '      <tr>
  45.             <td>' . htmlentities($naam) . '</td>
  46.             <td>' . htmlentities($strchallengesdone[$naam]) . '</td>
  47.             <td>' . htmlentities($punten[$naam]) . '</td>
  48.         <tr>';
  49. }
  50. echo '  </table>';
  51. ?>
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement