Guest User

Untitled

a guest
Dec 8th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. <?php
  2. //Performance rating = [(Total of opponents' ratings + 400 * (Wins - Losses)) / score]
  3. include('mysql.php');
  4. include('functions.php');
  5. $connn=mysqli_connect("localhost","root","","glamash");
  6.  
  7. // Get random 2
  8. $sql="SELECT * FROM images ORDER BY RAND() LIMIT 0,2";
  9. $result = $conn->query($sql);
  10.  
  11. while($row = $result->fetch_object()) {
  12. $images[] = (object) $row;
  13. }
  14.  
  15.  
  16. // Get the top10
  17. $result = $conn->query("SELECT *, ROUND(score) AS performance FROM images ORDER BY ROUND(score) DESC LIMIT 0,10");
  18. while($row = $result->fetch_object()) $top_ratings[] = (object) $row;
  19.  
  20. $result = $conn->query("SELECT * FROM `images` ORDER BY `wins` DESC LIMIT 10");
  21. while($row = $result->fetch_object()) $most_wins[] = (object) $row;
  22.  
  23. $wins = "SELECT SUM(`wins`) FROM `images`";
  24. if($query_run = mysqli_query($connn,$wins))
  25. {
  26. if($row= mysqli_fetch_array($query_run))
  27. {
  28. $wins= $row[0];
  29. }
  30. }
  31. $looses = "SELECT SUM(`losses`) FROM `images`";
  32. if($query_run = mysqli_query($connn,$looses))
  33. {
  34. if($row= mysqli_fetch_array($query_run))
  35. {
  36. $looses= $row[0];
  37. }
  38. }
  39. $hits = (int)(($wins+$looses)/2);
  40.  
  41.  
  42.  
  43. // Close the connection
  44. $conn->close();
  45.  
  46.  
  47. ?>
  48. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  49. <html xmlns="http://www.w3.org/1999/xhtml">
  50. <head>
  51. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  52. <title>GLA-MASH</title>
  53. <style type="text/css">
  54.  
  55. body, html {font-family:Arial, Helvetica, sans-serif;width:100%;margin:0;padding:0;text-align:center;background-color:#b4eeb4}
  56. h1 {background-color:#40e0d0;color:#fff;padding:20px 0;margin:0;}
  57. h2{font-family: 'Spectral SC', serif;}
  58. h4{color:#ff0000}
  59. a img {border:0;}
  60. td {font-size:11px;}
  61. .image {background-color:#eee;border:1px solid #ddd;border-bottom:1px solid #bbb;padding:5px;}
  62. .battle{font-family:Arial, Helvetica, sans-serif;font-size:20px;}
  63. </style>
  64. </head>
  65.  
  66. <body>
  67. <h1>GLA MASH</h1>
  68. <h4><marquee>If you want to change or remove your photo see the end of the page</marquee><h4>
  69.  
  70.  
  71. <h2>Whom you know more? Click to choose.</h2>
  72.  
  73. <center>
  74. <table>
  75. <tr>
  76. <td valign="top" class="image"><a href="rate.php?winner=<?=$images[0]->image_id?>&loser=<?=$images[1]->image_id?>"><img src="images/<?=$images[0]->filename?>" width="280" height="320"/></a></td>
  77. <td valign="top" class="image"><a href="rate.php?winner=<?=$images[1]->image_id?>&loser=<?=$images[0]->image_id?>"><img src="images/<?=$images[1]->filename?>" width="280" height="320"/></a></td>
  78. </tr>
  79. <tr>
  80. <td>Won: <?=$images[0]->wins?>, Lost: <?=$images[0]->losses?></td>
  81. <td>Won: <?=$images[1]->wins?>, Lost: <?=$images[1]->losses?></td>
  82. </tr>
  83. <tr>
  84. <td>Score: <?=$images[0]->score?></td>
  85. <td>Score: <?=$images[1]->score?></td>
  86. </tr>
  87. <tr>
  88. <td>Expected: <?=round(expected($images[1]->score, $images[0]->score), 4)?></td>
  89. <td>Expected: <?=round(expected($images[0]->score, $images[1]->score), 4)?></td>
  90. </tr>
  91. </table>
  92. </center>
  93.  
  94.  
  95. <h2>Top Score</h2>
  96. <center>
  97. <table>
  98.  
  99. <tr>
  100. <?php foreach($top_ratings as $image): ?>
  101.  
  102. <td valign="top" class="image" ><img src="images/<?=$image->filename?>" width="110" height="125" /></td>
  103. <?php endforeach; ?>
  104. </tr>
  105.  
  106. <tr>
  107. <?php foreach($top_ratings as $key => $image) : ?>
  108. <td valign="top">Score: <?=$image->score?></td>
  109. <?php endforeach ?>
  110. </tr>
  111. <tr>
  112. <?php foreach($top_ratings as $key => $image) : ?>
  113. <td valign="top">Performance: <?=$image->performance?></td>
  114. <?php endforeach ?>
  115. </tr>
  116. <tr>
  117. <?php foreach($top_ratings as $key => $image) : ?>
  118. <td valign="top">Won: <?=$image->wins?></td>
  119. <?php endforeach ?>
  120. </tr>
  121. <tr>
  122. <?php foreach($top_ratings as $key => $image) : ?>
  123. <td valign="top">Lost: <?=$image->losses?></td>
  124. <?php endforeach ?>
  125. </tr>
  126.  
  127.  
  128.  
  129. </table>
  130. </center>
  131.  
  132. <h2>Most Wins</h2>
  133. <center>
  134. <table>
  135.  
  136. <tr>
  137. <?php foreach($most_wins as $image): ?>
  138.  
  139. <td valign="top" class="image" ><img src="images/<?=$image->filename?>" width="110" height="125" /></td>
  140. <?php endforeach; ?>
  141. </tr>
  142.  
  143. <tr>
  144. <?php foreach($most_wins as $key => $image) : ?>
  145. <td valign="top">Score: <?=$image->score?></td>
  146. <?php endforeach ?>
  147. </tr>
  148.  
  149. <tr>
  150. <?php foreach($most_wins as $key => $image) : ?>
  151. <td valign="top">Won: <?=$image->wins?></td>
  152. <?php endforeach ?>
  153. </tr>
  154. <tr>
  155. <?php foreach($most_wins as $key => $image) : ?>
  156. <td valign="top">Lost: <?=$image->losses?></td>
  157. <?php endforeach ?>
  158. </tr>
  159.  
  160.  
  161.  
  162. </table>
  163. </center>
  164.  
  165. </br></br>
  166. <center>
  167. <b><p class="battle">Battles so far:-<?=$hits?></p></br>
  168. <p class="battle"><a href="score_formulae.txt">Checkout the score formulae</p></a>
  169.  
  170. </b>
  171. </center>
  172. </br></br>
  173. <p align="right" type="bold">A demo project by <a href="http://www.besttricks4u.com">Best Tricks 4 U</a></p>
  174. <p align="right"><a href="file.html">Do you want to change/remove your photo ?</a></p>
  175. </body>
  176. </html>
Add Comment
Please, Sign In to add comment