Jump to content
MakeWebGames

Recommended Posts

Posted

Im trying to create a page that shows all the NPC's in my game along with each NPC's stats, weapons and armor equiped.

I also want to show the number of times each NPC has been beaten. I was going to post it here when completed but I need a little help finishing it, lol

I cant get the query for the count to show.

NPCstats.php

<?php
include "sglobals.php";
{
print "



<table width=100% border=1 class=table>
<tr align=center>
<td class=h>ID</td>
<td class=h>NPC Username</td>
<td class=h>Level</td>
<td class=h>Unit</td>
<td class=h>Beaten</td>
<td class=h>STRENGHT</td>
<td class=h>AGILITY</td>
<td class=h>GRUARD</td>
<td class=h>PRI</td>
<td class=h>SEC</td>
<td class=h>ARM</td>
</tr>";
$q=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.user_level = 0 ");
while($r=$db->fetch_row($q))

print "<tr align=center>
<td>{$r['userid']}</td>
<td align=left>{$r['username']}</td>
<td>{$r['level']}</td>
<td>{$r['location']}</td>
<td>COUNT CODE HERE</td>
<td>{$r['strength']}</td>
<td>{$r['agility']}</td>
<td>{$r['guard']}</td>
<td>{$r['equip_primary']}</td>
<td>{$r['equip_secondary']}</td>
<td>{$r['equip_armor']}</td>
</tr>";
}
print "</table>";
$h->endpage();
?>

 

Any help finishing this would be greatly appriciated

Posted

I had:

[mysql]$count = mysql_query("SELECT * FROM challengebots WHERE cb_npcid=".$user['userid']) or die(mysql_error());

$count = mysql_fetch_assoc($count);[/mysql]

but I couldnt get it to work.

Posted
From the old battle tent
$a=$db->query("SELECT count(*) FROM challengesbeaten WHERE npcid=$v");
$times=$db->fetch_single($a);
tried that it gives me:

QUERY ERROR: You have an error in your SQL syntax; check the

manual that corresponds to your MySQL server version for the right

syntax to use near '' at line 1

Query was SELECT count(*) FROM challengesbeaten WHERE npcid=

Posted
$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'];
$a=$db->query("SELECT count(*) FROM challengesbeaten WHERE npcid=$v");
$times=$db->fetch_single($a);

and

print"$times";
Posted

OK Thanks that works

But now I have:

$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))
{
$v=$r['userid'];
$a=$db->query("SELECT count(*) FROM challengesbeaten WHERE npcid=$v");
$times=$db->fetch_single($a);
$q2=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.user_level = 0 ");
while($stat=$db->fetch_row($q2))

 

I currently have 16 NPC's in my game and its showing the same NPC 16 times then shows the next NPC 16 times and so on ????????????

the stats and other info are correct except the stats go in the correct order for the 16 and then start over on the next 16.

 

If that makes any sence...lol :huh:

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.

×
×
  • Create New...