Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
alsunj
/
blackjack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3207777c
authored
May 02, 2023
by
alsunj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
c9c2c245
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
scripts/htdocs/Table.php
scripts/htdocs/Table.php
0 → 100644
View file @
3207777c
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment