ddgamedesign Posted May 6, 2010 Share Posted May 6, 2010 Hey all, I have a battletent.php that is modified a little, but i'm wanting it to only show NPCs that are in the city you're currently in. Right now, i'm in cityid 2, but its still showing NPC's from city 1 (and of course when you click to attack them, it says you can only attack NPCs in the city you're in). I have NPCs in there that are set in city 2 already, so how do I modify this to get it to only display NPCs that are currently in the city you're in? Code: <?php include "globals.php"; print "<center>[img=cenpark.jpg]</center> <table width=100% cellspacing=1 class='table'><tr style='background: gray; '><th>Opponent Name</th><th>Level</th><th>Location</th><th>Action</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 ORDER BY RAND() LIMIT 5"); while($r=$db->fetch_row($q)) { $v=$r['userid']; $q2=$db->query("SELECT count(*) FROM challengesbeaten WHERE npcid=$userid"); $times=$db->fetch_single($q2); print "<tr><td><center>{$r['username']}</td><td><center>{$r['level']}"; print "</td><td><center>{$r['cityname']}</td><td>"; if($r['npcid']) { print "[i]Already[/i]"; } else { print "[url='npcattack.php?ID={$r[']<font color='red'><center>Attack![/url]</font>"; } print "</td></tr>"; } print "</table>"; $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted May 6, 2010 Share Posted May 6, 2010 [mysql]$q=$db->query("SELECT cb.*,u.*,c.npcid,cy.cityname FROM challengebots cb LEFT JOIN users u ON cb.cb_npcid=u.userid AND u.location='.$ir['location'].' LEFT JOIN challengesbeaten c ON c.npcid=u.userid AND c.userid=$userid LEFT JOIN cities cy ON u.location=cy.cityid ORDER BY RAND() LIMIT 5");[/mysql] May wanna edit out the *'s though... Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 7, 2010 Author Share Posted May 7, 2010 Nope....get: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING on line 5 when I use this line. Anyone have a clue? I'll send $2.50 Paypal to the first person who can figure this out. Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 7, 2010 Author Share Posted May 7, 2010 Got it (sorta) working. added the { } brackets and now it doesn't crash. The thing is, the NPCs have been set to be at Location 2, and i'm at location 2, and it just displays blank spaces. How do I set it so that only NPCs at Location 2 show up in the 5 choices? Quote Link to comment Share on other sites More sharing options...
ddgamedesign Posted May 7, 2010 Author Share Posted May 7, 2010 Never mind, User Error. Forgot the make the NPC additions NPC I guess, which in turn didn't let the NPCs be added to 'challengebots' in the database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.