Zonet
Web Developer
Very easy script. I'm improving my skills in PHP, so any suggestions would be really appreciated .
This counts how many players are citizen in X town.
Configuration in config, you have to set the town ids and town names.
:$
This counts how many players are citizen in X town.
Configuration in config, you have to set the town ids and town names.
PHP:
<?php
$main_content .= '<table border="0px" cellspacing="1" cellpadding="4" width="100%">
<tr><th>Town</th><th>Citizens</th></tr>';
$row = 1;
$worlds = $config['site']['worlds'];
$main_content .= '<b>Towns:</b> ';
foreach($worlds as $wid => $wname) {
switch($_GET['world']) {
case $wid:
$towns = $towns_list[$wid];
break;
}
$main_content .= '<a href="?subtopic=country&world='.$wid.'">'.$wname.'</a>, ';
foreach($towns as $idd => $name) {
$color = ($row % 2 ? $config['site']['darkborder'] : $config['site']['lightborder']);
$row++;
$main_content .= '<tr bgcolor="'.$color.'"><td>'.$name.'</td>';
$c = $SQL->query('SELECT id, COUNT(town_id) FROM players WHERE town_id = '.$idd.' AND world_id = '.$wid)->fetch();
$main_content .= '<td>'.$c[COUNT(town_id)].'</td></tr>';
}
}
$main_content .= '</table>';
?>
:$
Last edited: