Jump to content
  • 0

TOP RITCHEST STATS PROBLEM


Question

Recommended Posts

  • 0
Posted

One more problem with statistics. Wanna make top ritchest players. But Admin account is added too. How could i change it so that admin wont be shown?

$statement = "SELECT owner_id, count FROM items WHERE item_id = 57 AND count > 10 ORDER by count DESC LIMIT 10 ";
				$statement = $pdo->prepare($statement);
				$statement->execute();
				while($row = $statement->fetch()) {
						$statement2 = "SELECT char_name, accesslevel FROM characters WHERE obj_id = '".$row['owner_id']."' AND accesslevel <= 0";
						$statement2 = $pdo->prepare($statement2);
						$statement2->execute();
						$count++;
						$number = floor($row['count'] / 1000000);
						while($row = $statement2->fetch()) {
								
								$name =	$row['char_name'];
									
						}
							echo
							"
								<tr>
									<td class='number'>".$count."</td>
									<td class='name'>".$name."</td>
									<td class='value'>".$number."kk</td>
								</tr>
							";
						
					}

 

  • 0
Posted

Problem is that acceslevel is in different table. If it would be in same than ok. Those two tables has only one same cell, that is owner_id

  • 0
Posted
1 minute ago, admirolas3 said:

Problem is that acceslevel is in different table. If it would be in same than ok. Those two tables has only one same cell, that is owner_id

oh rly, then u can connect two tables or just check by owener id. example:

item_id = 57 AND count > 10 AND owner_id=1484984

  • 0
Posted

Your query is SQL injectable. Parameterise the parameters properly or else you expose your whole db.

  • 0
Posted
3 minutes ago, wongerlt said:

oh rly, then u can connect two tables or just check by owener id. example:

item_id = 57 AND count > 10 AND owner_id=1484984

I dont imagine how to do it. At first statement it gets 10 top numbers with an  player ids. Than with that id it checks for a player name and accesslevel in other statement. So if it founds that admin account was added, the top 10 becomes only 9. Because at first statemnet it takes 10 lines with an admin account..

  • 0
Posted
2 minutes ago, .Elfocrash said:

Your query is SQL injectable. Parameterise the parameters properly or else you expose your whole db.

Could you give an example?

  • 0
Posted
9 minutes ago, admirolas3 said:

Problem is that acceslevel is in different table. If it would be in same than ok. Those two tables has only one same cell, that is owner_id

 

google about sql left join

  • 0
Posted (edited)
SELECT i.owner_id, i.count from items as i
inner join characters c on c.obj_Id = i.owner_id 
WHERE i.item_id = 57 and i.count > 10 and c.accesslevel = 0
ORDER BY count DESC limit 10

 

Edited by .Elfocrash
  • 0
Posted
3 minutes ago, .Elfocrash said:

LEFT JOIN! HAHAHHAHAHAHAHAHAAA

 

Here is the query you need.


SELECT owner_id, count from items as i
inner join characters c on c.obj_Id = i.owner_id 
WHERE i.item_id = 57 and i.count > 10 and c.accesslevel = 0
ORDER BY count DESC limit 10

However read about prepared statements here: https://www.w3schools.com/php/php_mysql_prepared_statements.asp

 Could you add "char_name" in this query?

  • 0
Posted (edited)
2 minutes ago, admirolas3 said:

 Could you add "char_name" in this query?

 

Ofc you can, because you joined to the characters table so you can do c.* or c.char_name to get any column or a specific column from the table.

SELECT i.owner_id, c.char_name, i.count from items as i
inner join characters c on c.obj_Id = i.owner_id 
WHERE i.item_id = 57 and i.count > 10 and c.accesslevel = 0
ORDER BY count DESC limit 10
Edited by .Elfocrash
  • 0
Posted (edited)
9 minutes ago, .Elfocrash said:

 

Ofc you can, because you joined to the characters table so you can do c.* or c.char_name to get any column or a specific column from the table.


SELECT i.owner_id, c.char_name, i.count from items as i
inner join characters c on c.obj_Id = i.owner_id 
WHERE i.item_id = 57 and i.count > 10 and c.accesslevel = 0
ORDER BY count DESC limit 10

 

Edited by admirolas3
emty
  • 0
Posted
try {
				$pdo = new PDO("mysql:host=127.0.0.1; dbname=l2j", 'root', '');
				$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
				$pdo->query("SET NAMES 'utf8'");
			}
			catch(PDOException  $e) {
				echo "Connection failed: " . $e->getMessage();
		  }

$statement = "SELECT i.owner_id, c.char_name, i.count from items as i inner join characters c on c.obj_Id = i.owner_id WHERE i.item_id = 57 and i.count > 10 and c.accesslevel = 0 ORDER BY count DESC limit 10";
				$statement = $pdo->prepare($statement);
				$statement->execute();
				
				echo "<table style='width: 100%' cellpadding='2'>
						<tr>
							<td colspan='3' style='height: 24px' valign='top'><a href='e107_plugins/l2top/l2top.php?show=4'>Top ritchest players</a></td>
						</tr>
					";
				
				while($row = $statement->fetch()) {
						$count++;
						$number = floor($row['count'] / 1000000);
							echo
							"
								<tr>
									<td class='number'>".$count."</td>
									<td class='name'>".$row['char_name']."</td>
									<td class='value'>".$number."kk</td>
								</tr>
							";
						
					}

 

  • 0
Posted
1 minute ago, admirolas3 said:

The whole code looks like that. Works like a charm. Thanks. What you think, everything looks ok?

Yeap, that's all you need.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Hello Everyone  I hope you missed Old nostalgia BNB , is time to come back and be ready for the new journey  L2 BnB C3 Website: https://l2bnb.eu/ Discord: https://discord.gg/jaCJKYXgYZ Max Level 75 Max Grade (A) Safe:3 , Max:16 Anti-Botting. Auto learning skills , Auto Loot , Auto Create Account Subclass (NO) quest. Retail Buffs/DS Time ,Need Buffer Char (NO NPC Buffer) OfflineShop,OfflineCraft,ChangePass No GM Shop,No Global Gk,No Donate,Free Teleport only LVL 1 commands: .offline , .changepassword 99+% Retail 1+1 Window Per Pc BASIC FEATURES: Exp/SP: x 3 Adena: x3 Drop: х3 Spoil: x3 Support 24/7 GLOBAL COMMUNITY
    • 亲爱的朋友们,我们很高兴向您介绍我们的全新服务 —— KYC 实名认证,适用于任何平台!️ 我们为加密货币交易所、在线市场、社交网络、主机服务商、赌场及其他合法网站提供实名认证服务。认证可通过护照或驾驶证完成。不支持任何涉及非法活动的网站。 可用国家: 东欧:俄罗斯、乌克兰、白俄罗斯、乌兹别克斯坦、亚美尼亚、吉尔吉斯斯坦、哈萨克斯坦 — $30–33 欧盟(西欧,通常为拉脱维亚和爱沙尼亚) — $80–88 非洲:尼日利亚、肯尼亚 — $30–33 如果您需要注册并验证您的账户,总金额将额外收取 10% 手续费。 如需申请 KYC 认证或咨询其他问题,请通过以下方式联系我们: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store SOCNET 商店有效链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 消息应用便捷访问商店。 Telegram 星星购买机器人:进入 – 快速且优惠地购买 Telegram 星星。 SMM 面板:进入 – 推广您的社交媒体账户。 我们为您准备了最新的促销与特别优惠,用于购买我们的产品与服务: 1. 使用优惠码 OCTOBER2025(8% 折扣)即可在 9 月于我们的商店(网站或机器人)购物享受优惠!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获得 $1 商店余额或 10–20% 折扣 —— 只需在网站注册后按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..." – 在我们的论坛帖中发布即可! 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道及星星购买机器人中举行 Telegram 星星赠送活动! 新闻资讯: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh
    • 亲爱的朋友们,我们很高兴向您介绍我们的全新服务 —— KYC 实名认证,适用于任何平台!️ 我们为加密货币交易所、在线市场、社交网络、主机服务商、赌场及其他合法网站提供实名认证服务。认证可通过护照或驾驶证完成。不支持任何涉及非法活动的网站。 可用国家: 东欧:俄罗斯、乌克兰、白俄罗斯、乌兹别克斯坦、亚美尼亚、吉尔吉斯斯坦、哈萨克斯坦 — $30–33 欧盟(西欧,通常为拉脱维亚和爱沙尼亚) — $80–88 非洲:尼日利亚、肯尼亚 — $30–33 如果您需要注册并验证您的账户,总金额将额外收取 10% 手续费。 如需申请 KYC 认证或咨询其他问题,请通过以下方式联系我们: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store SOCNET 商店有效链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 消息应用便捷访问商店。 Telegram 星星购买机器人:进入 – 快速且优惠地购买 Telegram 星星。 SMM 面板:进入 – 推广您的社交媒体账户。 我们为您准备了最新的促销与特别优惠,用于购买我们的产品与服务: 1. 使用优惠码 OCTOBER2025(8% 折扣)即可在 9 月于我们的商店(网站或机器人)购物享受优惠!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获得 $1 商店余额或 10–20% 折扣 —— 只需在网站注册后按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..." – 在我们的论坛帖中发布即可! 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道及星星购买机器人中举行 Telegram 星星赠送活动! 新闻资讯: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh
    • 亲爱的朋友们,我们很高兴向您介绍我们的全新服务 —— KYC 实名认证,适用于任何平台!️ 我们为加密货币交易所、在线市场、社交网络、主机服务商、赌场及其他合法网站提供实名认证服务。认证可通过护照或驾驶证完成。不支持任何涉及非法活动的网站。 可用国家: 东欧:俄罗斯、乌克兰、白俄罗斯、乌兹别克斯坦、亚美尼亚、吉尔吉斯斯坦、哈萨克斯坦 — $30–33 欧盟(西欧,通常为拉脱维亚和爱沙尼亚) — $80–88 非洲:尼日利亚、肯尼亚 — $30–33 如果您需要注册并验证您的账户,总金额将额外收取 10% 手续费。 如需申请 KYC 认证或咨询其他问题,请通过以下方式联系我们: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store SOCNET 商店有效链接: 数字商品商店(网站):进入 商店 Telegram 机器人:进入 – 通过 Telegram 消息应用便捷访问商店。 Telegram 星星购买机器人:进入 – 快速且优惠地购买 Telegram 星星。 SMM 面板:进入 – 推广您的社交媒体账户。 我们为您准备了最新的促销与特别优惠,用于购买我们的产品与服务: 1. 使用优惠码 OCTOBER2025(8% 折扣)即可在 9 月于我们的商店(网站或机器人)购物享受优惠!首次购买还可使用优惠码 SOCNET(15% 折扣)。 2. 获得 $1 商店余额或 10–20% 折扣 —— 只需在网站注册后按照以下格式留言:"SEND ME BONUS, MY USERNAME IS..." – 在我们的论坛帖中发布即可! 3. 首次试用 SMM 面板可获得 $1 奖励 —— 只需在网站(支持)提交标题为 “Get Trial Bonus” 的工单。 4. 每周在我们的 Telegram 频道及星星购买机器人中举行 Telegram 星星赠送活动! 新闻资讯: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock