This solution is working, but I am not sure if it is optimal & safe. I am 100% PHP newbie and not sure if I am needed to use PDO connection but I read somewhere that PDO is the safest way so I started with that.
config.php
<?php
define('USER', '');
define('PASSWORD', '');
define('HOST', '');
define('DATABASE', '');
try {
$connection = new PDO("mysql:host=".HOST.";dbname=".DATABASE, USER, PASSWORD);
} catch (PDOException $e) {
exit("Error: " . $e->getMessage());
}
?>
index.php (there i want to display the total users)
<?php
include 'includes/config.php';
$stmt = $connection->query('SELECT * FROM users');
$row_count = $stmt->rowCount();
<?
...
HTML CODE
...
<p> <?php echo $row_count; ?> </p>