seany123 Posted September 16, 2008 Share Posted September 16, 2008 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 More sharing options...
Guardian-Mage Posted September 16, 2008 Share Posted September 16, 2008 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 More sharing options...
seany123 Posted September 16, 2008 Author Share Posted September 16, 2008 when you say it would be slow, do you mean that it would make that page slow? or the entire site or what? Link to comment https://forums.phpfreaks.com/topic/124566-help-needed/#findComment-643399 Share on other sites More sharing options...
Guardian-Mage Posted September 17, 2008 Share Posted September 17, 2008 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 More sharing options...
seany123 Posted September 17, 2008 Author Share Posted September 17, 2008 No idea how to do that, will probably look into it soon Link to comment https://forums.phpfreaks.com/topic/124566-help-needed/#findComment-644157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.