Jump to content
MakeWebGames

Battle tent issue


modernmafiia
 Share

Recommended Posts

Hello guys having a bit of a problem displaying results in battle tent,

what i have done is removed the limit cap so you can attack it as many times you want, what issue is basically the count should display as one thing

so for example:

NPC=GOBLIN

OWNED=300 time

But say i attacked it again

it will repeat the row so it will display the results twice :

NPC=GOBLIN

OWNED=300 time

 

NPC=GOBLIN

OWNED=300 time

That is because in the table or in the coding its not filtering that out, i want it so it does not matter who/which userid attack it how many times just to count how many times from the table its been defeated not to get the userid invovled because it will end up repeating it.

Heres the code:

<?php
include "globals.php";
print "<h3>Battle Tent</h3>
<b>Welcome to the battle tent! Here you can challenge NPCs for money.</b>
<table width=100% cellspacing=1 class='table'><tr style='background: gray; '><th>Bot Name</th><th>Level</th><th>Times Owned</th><th>Ready To Be Challenged?</th><th>Location</th><th>Money Won</th><th>Challenge</th></tr>";
$q=$db->query("SELECT cb.*,u.*,c.npcid,cy.cityname FROM challengebots cb LEFT JOIN users u ON cb.cb_npcid=u.userid LEFT JOIN challengesbeaten c ON c.npcid=u.userid AND c.userid=$userid LEFT JOIN cities cy ON u.location=cy.cityid");
while($r=$db->fetch_row($q))
{
$earn=$r['cb_money'];
$v=$r['userid'];
$qt=$db->query("SELECT count(*) FROM challengesbeaten WHERE npcid=$v");
$times=$db->fetch_single($qt);
print "<tr><td>{$r['username']}</td><td>{$r['level']}</td><td>$times</td><td>";
if($r['hp'] >= $r['maxhp']/2 and $r['location']==$ir['location'] and !$ir['hospital'] and !$ir['jail'] and !$r['hospital'] and !$r['jail']) { print "<font color=green>Yes</font>"; } else { print "<font color=red>No</font>"; }
print "</td><td>{$r['cityname']}</td><td>$earn</td><td>";

print "[<a href='attack.php?ID={$r['userid']}'>Challenge</a>]";

print "</td></tr>";
}
print "</table>";
$h->endpage();
?>
Edited by modernmafiia
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...