Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. $highfives = array();
  3. $servername = "";
  4. $username = "";
  5. $password = "";
  6. $dbname = "";
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8. $sql = "select uid, count(distinct ip) from highfives t group by uid ORDER BY `count(distinct ip)` DESC";
  9. $result = $conn->query($sql);
  10. $count = 0;
  11. while($row = $result->fetch_assoc()) {
  12. $count++;
  13. $highfives[$count]['uid'] = $row['uid'];
  14. $highfives[$count]['amount'] = $row['count(distinct ip)'];
  15. $sql = "select username, email from users";
  16. $resultt = $conn->query($sql);
  17. while($rows = $resultt->fetch_assoc()) {
  18. if (md5($rows['email']) == $row['uid']) {
  19. $highfives[$count]['username'] = $rows['username'];
  20. }
  21. }
  22. }
  23. $winner = "";
  24. $amount = 0;
  25. foreach($highfives as $rows) {
  26. if ($amount < $rows['amount']) {
  27. $winner = $rows['username'];
  28. $amount = $rows['amount'];
  29. }
  30. }
  31. echo "The winner is ".$winner." with ".$amount." unique highfives!"
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement