DEVILofDARKNESS Posted August 11, 2009 Share Posted August 11, 2009 If I run this script with user Test that has leader: no, I get: This nation doesn't have any weapons. Although I should get This: You don't have any weapons... I echoed $leader on an other page and it gave as output: no (which it should be), but if I echo it on the page it gives: yes although it is the same code which generates if it is a leader or not. I'm a bit confused??? (You should actually only see to the last lines of the code, not to the query, the query is only loaded when there are results found, in this case their aren't...) weapons.php <?php session_start(); require_once './config.php'; require_once './checkuserid.php'; $query = "SELECT leader FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($leader) = mysql_fetch_row($result); /* CoRTable = Civilian or Ruler Table: Civilians: user_weapons Rulers: region_weapons CoRIdName: Civilian: user_id Ruler: nation_id CoRId; The Id from the user or nation YW: YourWeapons */ if($leader = 'yes'){ $CoRTable = "region_weapons"; $CoRIdName = "region_id"; $CoRId = $nationid; }else{ $CoRTable = "user_weapons"; $CoRIdName = "user_id"; $CoRId = $userid; } ?> <html> <head> <title>CriticalInvasion - Weapons</title> <link href="./css/index.css" rel="stylesheet" type="text/css"> </head> <body> <?php $query = "SELECT * FROM " . $CoRTable . " INNER JOIN weapons ON " . $CoRTable . ".weapon_id = weapons.weapon_id WHERE " . $CoRIdName . " = '$CoRId'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); if($numrows > 0){ while($YW = mysql_fetch_array($result)){ echo "<div id='attack_left'>" . $YW['weapon_name'] . "</div><div id='attack_right'>" . $YW['ammount'] . "</div>"; } }elseif(($numrows <= 0) && ($leader = 'yes')){ echo "<div id='text_text'>This nation doesn't have any weapons...</div>"; }elseif(($numrows <= 0) && ($leader = 'no')){ echo "<div id='text_text'>You don't have any weapons...</div>"; } ?> </body> </html> edit.php <?php session_start(); require_once './config.php'; require_once './checkuserid.php'; $query = "SELECT leader FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($leader) = mysql_fetch_row($result); ?> <html> <head> <title>CriticalInvasion - Edit</title> <link href="./css/index.css" rel="stylesheet" type="text/css"> </head> <body> <div id='text_text'> <? echo $userid . " " . $leader; ?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted August 11, 2009 Share Posted August 11, 2009 You are assigning a value rather than comparing elseif(($numrows <= 0) && ($leader = 'yes')){ elseif(($numrows <= 0) && ($leader == 'yes')){ Also why would the number of rows be less that 0. You cant return a negative number of records elseif(!$numrows && $leader == 'yes'){ Quote Link to comment Share on other sites More sharing options...
DEVILofDARKNESS Posted August 11, 2009 Author Share Posted August 11, 2009 Thanks!, it was the if($leader = 'yes') that had to be if($leader == 'yes) Than you, how couldn't I see that 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.