Newbie Spellweaver
- Joined
- Aug 10, 2020
- Messages
- 18
- Reaction score
- 3
i am using curl becouse the game server and web server are not in same server
to display it one by one into your homepage
call one by one
Data updated every the page refreshed
PHP:
// Total Account or Account.php
<?php
// Connect to the database
$serverName = "ServerName";
$connectionOptions = array(
"Database" => "dnmembership",
"UID" => "Username",
"PWD" => "Password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
// Check connection
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
// Execute the SELECT query
$query = "SELECT COUNT(*) AS TotalCount FROM Accounts";
$result = sqlsrv_query($conn, $query);
if ($result === false) {
die(print_r(sqlsrv_errors(), true));
}
// Fetch the results
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$totalCount = $row['TotalCount'];
// Print the results
echo "$totalCount";
// Free the result set
sqlsrv_free_stmt($result);
// Close the database connection
sqlsrv_close($conn);
PHP:
// Total Character or character.php
<?php
// Connect to the database
$serverName = "ServerName";
$connectionOptions = array(
"Database" => "dnmembership",
"UID" => "Username",
"PWD" => "Password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
// Check connection
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
// Execute the SELECT query
$query = "SELECT COUNT(*) AS TotalCount FROM Characters";
$result = sqlsrv_query($conn, $query);
if ($result === false) {
die(print_r(sqlsrv_errors(), true));
}
// Fetch the results
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$totalCount = $row['TotalCount'];
// Print the results
echo "$totalCount";
// Free the result set
sqlsrv_free_stmt($result);
// Close the database connection
sqlsrv_close($conn);
Code:
// Total Online or online.php
<?php
// Connect to the database
$serverName = "ServerName";
$connectionOptions = array(
"Database" => "dnmembership",
"UID" => "Username",
"PWD" => "Password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);
// Check connection
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
// Execute the SELECT query
$query = "SELECT COUNT(*) AS TotalCount FROM DNAuth WHERE CertifyingStep > 0";
$result = sqlsrv_query($conn, $query);
if ($result === false) {
die(print_r(sqlsrv_errors(), true));
}
// Fetch the results
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$totalCount = $row['TotalCount'];
// Print the results
echo "$totalCount";
// Free the result set
sqlsrv_free_stmt($result);
// Close the database connection
sqlsrv_close($conn);
i put that code into curl folderTo view the content, you need to sign in or register
to display it one by one into your homepage
PHP:
// add this on your index.php or any page you want to show the info
<?php
function ethernumAPI($method) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://localhost/curl/" . $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}
?>
call one by one
PHP:
<?php ethernumAPI("account.php"); ?>
PHP:
<?php ethernumAPI("character.php"); ?>
PHP:
<?php ethernumAPI("online.php"); ?>
Data updated every the page refreshed