9019first of all id of the unban doll?
- displays character which has more than 5 unban doll
If player_id selected more or equal to 5 then display name
else not
SELECT player_id,name FROM player_items WHERE itemtype = 9019
SELECT `player_id`, COUNT(*) FROM `player_items` WHERE `itemtype` = 2160 GROUP BY `player_id` HAVING COUNT(*) >= 5 ORDER BY COUNT(*) DESC
<?php
$sql=mysql_query("SELECT player_id,name FROM player_items WHERE itemtype = 9019");
if (mysql_num_rows($sql) > 0){
while($r = mysql_fetch_array($sql)){
$player=$sql[0];
$getDollNum=mysql_query("SELECT * FROM player_items WHERE player_id='$player' AND itemtype=9019");
if(mysql_num_rows($getDollNum) > 5){
echo $sql[0];}
}
}
else{
echo "None of players has an unban doll";}
?>
Here you go.
BTW second field is the quanty of unban scroll/doll etc... AH remember to change the itemtype to your itemidCode:SELECT `player_id`, COUNT(*) FROM `player_items` WHERE `itemtype` = 2160 GROUP BY `player_id` HAVING COUNT(*) >= 5 ORDER BY COUNT(*) DESC
<?php
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = POT::getInstance()->getDBHandle();
global $config;
$query = $SQL->query("SELECT `player_id`, COUNT(*) FROM `player_items` WHERE `itemtype` = 2160 GROUP BY `player_id` HAVING COUNT(*) >= 2 ORDER BY COUNT(*) DESC");
echo 'All of the players of ' . $config['server_name'] .' with 5 or more unban dolls are listed below.<br/>
<br />
<table width="100%">
<tbody>
<tr><td width="60%"><b>Name</b></td><td><b>Status</b></td></tr>';
$aaa = 0;
foreach($query as $info)
{
$player = $ots->createObject('Player');
$player->find($info['player_id']); ;
echo '<tr>
<td width="60%"><a href="/index.php/character/view/'.$info['player_id'].'">'.$info['player_id'].'</a></td>
<td><font color="';
echo ($player->isOnline()) ? 'green' : 'red';
echo '">';
echo ($player->isOnline()) ? 'Online' : 'Offline';
echo '</font></td>
</tr>';
$aaa++;
}
echo '</tbody>
</table>';
?>
Okey! ALMOST! got it to work
The problem is that the name isn't selected just the player id, will try when I come back home, if someone else haven't already solved this
Item count - A fast view how it looks like right now!
<?php
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = POT::getInstance()->getDBHandle();
global $config;
$query = $SQL->query("SELECT `players`.`name`,`players`.`online`, COUNT(*) as `dolls` FROM `player_items`,`players` WHERE `player_items`.`itemtype` = 2160 AND `player_items`.`player_id` = `players`.`id` GROUP BY `players`.`name` HAVING COUNT(*) >= 5 ORDER BY COUNT(*) DESC");
echo('All of the players of ' . $config['server_name'] .' with 5 or more unban dolls are listed below.<br /><br />
<table width="100%"><tbody>
<tr>
<td width="60%"><b>Name</b></td>
<td><b>Status</b></td>
<td><b>Unban Dolls</b></td>
</tr>');
foreach($query as $info)
echo('<tr>
<td width="60%"><a href="/index.php/character/view/'.urlencode($info['name']).'">'.$info['name'].'</a></td>
<td><font color="'.($info['online'] == 1 ? 'green">Online' : 'red">Offline').'</font></td>
<td>'.$info['dolls'].'</td>
</tr>');
echo('</tbody></table>');
?>
<?php
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = POT::getInstance()->getDBHandle();
global $config;
## ---Config---
$item_id = 2160;
$total_item = 2;
## ---End of config!---
$query = $SQL->query("SELECT `players`.`name`,`players`.`online`, COUNT(*) as `dolls` FROM `player_items`,`players` WHERE `player_items`.`itemtype` = ".$item_id." AND `player_items`.`player_id` = `players`.`id` GROUP BY `players`.`name` HAVING COUNT(*) >=".$total_item." ORDER BY COUNT(*) DESC");
echo('All of the players of ' . $config['server_name'] .' with '.$total_item.' or more unban dolls are listed below.<br /><br />
<table width="100%"><tbody>
<tr>
<td width="60%"><b>Name</b></td>
<td><b>Status</b></td>
<td><b>Unban Dolls</b></td>
</tr>');
foreach($query as $info)
echo('<tr>
<td width="60%"><a href="/index.php/character/view/'.urlencode($info['name']).'">'.$info['name'].'</a></td>
<td><font color="'.($info['online'] == 1 ? 'green">Online' : 'red">Offline').'</font></td>
<td>'.$info['dolls'].'</td>
</tr>');
echo('</tbody></table>');
?>