06.05.2016, 01:37
(
Last edited by KevinReinke; 07/05/2016 at 08:28 PM.
Reason: Forgot two $s.
)
Hello there,
For anyone interested in how this can be done:
connection.php:
top_kills.php:
For anyone interested in how this can be done:
connection.php:
PHP Code:
<?php
$database_host = "localhost";
$database_user = "root";
$database_pass = "";
$database_db = "database_name";
$connection = new PDO("mysql:host=$database_host;dbname=$database_db;charset=utf8", $database_user, $database_pass);
$connection -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
PHP Code:
<?php
include_once 'connection.php';
$query = $connection -> prepare("SELECT `name`, `kills` FROM `accounts` ORDER BY `kills` DESC LIMIT 15");
if($query -> execute())
{
$row_count = $query -> rowCount();
if($row_count)
{
while($query_result = $query -> fetch())
{
echo $query_result['name'] . ': ' . $query_result['kills'] . '<br>';
}
}
}
?>
