Location: PHPKode > projects > Trunk.net > viewtickets.php
<?

require "include/functions.php";


dbconn();

loggedinorreturn();

stdhead("Tickets Sold");

$res = mysql_query("SELECT * FROM lottery_config") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res))
$arr_config[$arr['name']] = $arr['value'];

$endday = $arr_config['end_date'];

if (!$arr_config["enable"])
stderr("Sorry", "Lottery is disabled.");

print("iMT Lottery Ends: <b>" . $endday . "</b><br /><br />");

?>
<table border="1" width="600" cellpadding="5">
<tr>
<td class="tabletitle">#</td>
<td class="tabletitle">Username</td>
<td class="tabletitle">Number of tickets</td>
<td class="tabletitle">Uploaded</td>
<td class="tabletitle">Downloaded</td>
<td class="tabletitle">Ratio</td>
</tr>
<?
$sql = mysql_query("SELECT user FROM tickets") or die (mysql_error());
while ($myrow = mysql_fetch_assoc($sql))
$user[] = $myrow["user"];
$user = array_values(array_unique($user));
for ($i = 0; $i < sizeof($user); $i++)
{
$tickets[] = mysql_num_rows(mysql_query("SELECT * FROM tickets WHERE user=$user[$i]"));
$username[] = end(mysql_fetch_row(mysql_query("SELECT username FROM users WHERE id=$user[$i]")));
$id[] = end(mysql_fetch_row(mysql_query("SELECT id FROM users WHERE id=$user[$i]")));
$uploaded[] = mksize(end(mysql_fetch_row(mysql_query("SELECT uploaded FROM users WHERE id=$user[$i]"))));
$downloaded[] = mksize(end(mysql_fetch_row(mysql_query("SELECT downloaded FROM users WHERE id=$user[$i]"))));
$ratio[] = end(mysql_fetch_row(mysql_query("SELECT downloaded FROM users WHERE id=$user[$i]")));
$ratio2[] = end(mysql_fetch_row(mysql_query("SELECT uploaded FROM users WHERE id=$user[$i]")));
echo "<tr><td class=tableb>" . ($i + 1) . "</td><td class=tableb><a href=userdetails.php?id=$id[$i]>$username[$i]</a></td><td class=tableb>$tickets[$i]</td><td class=tableb>$uploaded[$i]</td><td class=tableb>$downloaded[$i]</td><td class=tableb>" . number_format($ratio2[$i] / $ratio[$i], 3) . "</td></tr>";
}
?>
</table>
<?

stdfoot();
die;
?>
Return current item: Trunk.net