Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Performance rating = [(Total of opponents' ratings + 400 * (Wins - Losses)) / score]
- include('mysql.php');
- include('functions.php');
- $connn=mysqli_connect("localhost","root","","glamash");
- // Get random 2
- $sql="SELECT * FROM images ORDER BY RAND() LIMIT 0,2";
- $result = $conn->query($sql);
- while($row = $result->fetch_object()) {
- $images[] = (object) $row;
- }
- // Get the top10
- $result = $conn->query("SELECT *, ROUND(score) AS performance FROM images ORDER BY ROUND(score) DESC LIMIT 0,10");
- while($row = $result->fetch_object()) $top_ratings[] = (object) $row;
- $result = $conn->query("SELECT * FROM `images` ORDER BY `wins` DESC LIMIT 10");
- while($row = $result->fetch_object()) $most_wins[] = (object) $row;
- $wins = "SELECT SUM(`wins`) FROM `images`";
- if($query_run = mysqli_query($connn,$wins))
- {
- if($row= mysqli_fetch_array($query_run))
- {
- $wins= $row[0];
- }
- }
- $looses = "SELECT SUM(`losses`) FROM `images`";
- if($query_run = mysqli_query($connn,$looses))
- {
- if($row= mysqli_fetch_array($query_run))
- {
- $looses= $row[0];
- }
- }
- $hits = (int)(($wins+$looses)/2);
- // Close the connection
- $conn->close();
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>GLA-MASH</title>
- <style type="text/css">
- body, html {font-family:Arial, Helvetica, sans-serif;width:100%;margin:0;padding:0;text-align:center;background-color:#b4eeb4}
- h1 {background-color:#40e0d0;color:#fff;padding:20px 0;margin:0;}
- h2{font-family: 'Spectral SC', serif;}
- h4{color:#ff0000}
- a img {border:0;}
- td {font-size:11px;}
- .image {background-color:#eee;border:1px solid #ddd;border-bottom:1px solid #bbb;padding:5px;}
- .battle{font-family:Arial, Helvetica, sans-serif;font-size:20px;}
- </style>
- </head>
- <body>
- <h1>GLA MASH</h1>
- <h4><marquee>If you want to change or remove your photo see the end of the page</marquee><h4>
- <h2>Whom you know more? Click to choose.</h2>
- <center>
- <table>
- <tr>
- <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>
- <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>
- </tr>
- <tr>
- <td>Won: <?=$images[0]->wins?>, Lost: <?=$images[0]->losses?></td>
- <td>Won: <?=$images[1]->wins?>, Lost: <?=$images[1]->losses?></td>
- </tr>
- <tr>
- <td>Score: <?=$images[0]->score?></td>
- <td>Score: <?=$images[1]->score?></td>
- </tr>
- <tr>
- <td>Expected: <?=round(expected($images[1]->score, $images[0]->score), 4)?></td>
- <td>Expected: <?=round(expected($images[0]->score, $images[1]->score), 4)?></td>
- </tr>
- </table>
- </center>
- <h2>Top Score</h2>
- <center>
- <table>
- <tr>
- <?php foreach($top_ratings as $image): ?>
- <td valign="top" class="image" ><img src="images/<?=$image->filename?>" width="110" height="125" /></td>
- <?php endforeach; ?>
- </tr>
- <tr>
- <?php foreach($top_ratings as $key => $image) : ?>
- <td valign="top">Score: <?=$image->score?></td>
- <?php endforeach ?>
- </tr>
- <tr>
- <?php foreach($top_ratings as $key => $image) : ?>
- <td valign="top">Performance: <?=$image->performance?></td>
- <?php endforeach ?>
- </tr>
- <tr>
- <?php foreach($top_ratings as $key => $image) : ?>
- <td valign="top">Won: <?=$image->wins?></td>
- <?php endforeach ?>
- </tr>
- <tr>
- <?php foreach($top_ratings as $key => $image) : ?>
- <td valign="top">Lost: <?=$image->losses?></td>
- <?php endforeach ?>
- </tr>
- </table>
- </center>
- <h2>Most Wins</h2>
- <center>
- <table>
- <tr>
- <?php foreach($most_wins as $image): ?>
- <td valign="top" class="image" ><img src="images/<?=$image->filename?>" width="110" height="125" /></td>
- <?php endforeach; ?>
- </tr>
- <tr>
- <?php foreach($most_wins as $key => $image) : ?>
- <td valign="top">Score: <?=$image->score?></td>
- <?php endforeach ?>
- </tr>
- <tr>
- <?php foreach($most_wins as $key => $image) : ?>
- <td valign="top">Won: <?=$image->wins?></td>
- <?php endforeach ?>
- </tr>
- <tr>
- <?php foreach($most_wins as $key => $image) : ?>
- <td valign="top">Lost: <?=$image->losses?></td>
- <?php endforeach ?>
- </tr>
- </table>
- </center>
- </br></br>
- <center>
- <b><p class="battle">Battles so far:-<?=$hits?></p></br>
- <p class="battle"><a href="score_formulae.txt">Checkout the score formulae</p></a>
- </b>
- </center>
- </br></br>
- <p align="right" type="bold">A demo project by <a href="http://www.besttricks4u.com">Best Tricks 4 U</a></p>
- <p align="right"><a href="file.html">Do you want to change/remove your photo ?</a></p>
- </body>
- </html>
Add Comment
Please, Sign In to add comment