Jump to content

help needed.


seany123

Recommended Posts

Well im making a game and im wanting to display a world stats page, which shows the total amount of money, points, players etc in the game.

 

 

in my database i have a 'players' table (which is where the list of players are, some of the value in that table include, 'money' , 'points' , 'bank'.

 

So what im wanting is for a script which will add all the players 'money' together and display it.

and then maybe a average aswell

 

can this be done?

Link to comment
https://forums.phpfreaks.com/topic/124566-help-needed/
Share on other sites

It would be slow, so I recommend a cron running once an hour to update it. You would select all rows, and add them together.

 

$totalCash = 0;

$query = "SELECT `money` FROM `players`";
$execute = mysql_query($query);

while ($i=mysql_fetch_row($execute)) {
   $totalCash += intval($i[0]);
}

Link to comment
https://forums.phpfreaks.com/topic/124566-help-needed/#findComment-643397
Share on other sites

Every time that page was loaded, it would take a while, but only for that page. It is just that the script must handle so much data, it gets slowed down. So you could have that page load the stats from stats.xml, and every 1 hour, run a cron (A php script) that updates that XML file with the new stats.

Link to comment
https://forums.phpfreaks.com/topic/124566-help-needed/#findComment-644153
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.