Commit 3207777c by alsunj

Upload New File

parent c9c2c245
Showing with 45 additions and 0 deletions
<?php
$con = mysqli_connect('localhost', 'root','root', 'unity', '3306');
if(mysqli_connect_errno())
{
echo "1";
exit();
}
// päring tabelist username tabelist 13 kasutajanime ja nende pangaseisu sorteerides need suurema pangaseisuga eespool
$bank = "SELECT username, bank FROM users ORDER BY bank DESC LIMIT 13";
//ühendub andmebaasile ligi $bank päringuga
$name = mysqli_query($con, $bank) or die("4: ei saa kasutajat lisada");;
if ($name->num_rows > 0) {
// Loop through each row and get the username
//vaatab mitu kasutajat leiab kuni 13, ning salvestab $username ja $bank
while
($row_users = $name->fetch_assoc()) {
$username = $row_users["username"];
$bank = $row_users["bank"];
// päring player kust ta võtab player tabelist sama kasutajanime kaotused ja võidud, kasutajanimi eelnevast tabelist
$player = "SELECT wins, loses FROM player WHERE username = '$username'";
// Execute the query
$playertulemus = mysqli_query($con, $player) or die ("5; ei saa teise tabelile ligi");
// väljastab saadud tulemused
if ($playertulemus->num_rows > 0) {
while($row_player = $playertulemus->fetch_assoc()) {
$wins = $row_player["wins"];
$loses = $row_player["loses"];
echo $username . ' ' . $bank . ' ' . $wins . ' ' . $loses . "<br>";
}
}
}
}
else {
echo "0 results";
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment