Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $highfives = array();
- $servername = "";
- $username = "";
- $password = "";
- $dbname = "";
- $conn = new mysqli($servername, $username, $password, $dbname);
- $sql = "select uid, count(distinct ip) from highfives t group by uid ORDER BY `count(distinct ip)` DESC";
- $result = $conn->query($sql);
- $count = 0;
- while($row = $result->fetch_assoc()) {
- $count++;
- $highfives[$count]['uid'] = $row['uid'];
- $highfives[$count]['amount'] = $row['count(distinct ip)'];
- $sql = "select username, email from users";
- $resultt = $conn->query($sql);
- while($rows = $resultt->fetch_assoc()) {
- if (md5($rows['email']) == $row['uid']) {
- $highfives[$count]['username'] = $rows['username'];
- }
- }
- }
- $winner = "";
- $amount = 0;
- foreach($highfives as $rows) {
- if ($amount < $rows['amount']) {
- $winner = $rows['username'];
- $amount = $rows['amount'];
- }
- }
- echo "The winner is ".$winner." with ".$amount." unique highfives!"
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement