WarMad Posted November 25, 2016 Share Posted November 25, 2016 for my hall of fame i have battle stats on there but what i want it to do is show YOUR name and position and then show everyone elses position as normal but there names should say hidden instead of actually showing everyone elses names if i did not explain that very well let me know Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 26, 2016 Share Posted November 26, 2016 if(my['userid'] == returned['userid']) { show name } else { show 'unknown'; } Quote Link to comment Share on other sites More sharing options...
WarMad Posted November 28, 2016 Author Share Posted November 28, 2016 thanks :p feel kinda slow for not knowing that haha i have been doing a lot and still couldnt do that i guess i should have tried a little harder Quote Link to comment Share on other sites More sharing options...
SRB Posted November 29, 2016 Share Posted November 29, 2016 Why would you not do this at mysql level and save yourself some resources and lines of code? MySQL runs faster than PHP, so makes logical sense to pull the data at that level. For example : <?php $userid = $_SESSION['userid']; $sql = <<<SQL SELECT IF(userid == $userid, username, 'Unknown') AS name FROM users LEFT JOIN userstats USING (userid) ORDER BY (strength + agility + guard + IQ) DESC LIMIT 20 SQL; $rs = $db->query($sql); if ($db->num_rows($rs)) { while ($row = $db->fetch_row($rs)) { echo $row['name'] . '<br />'; } } Note I am not sure if the ORDER BY has all the right fields or if the $db class is even calling the right function names, but from memory, this looks about right; 2 Quote Link to comment Share on other sites More sharing options...
WarMad Posted November 29, 2016 Author Share Posted November 29, 2016 thanks i will give that a try when i get a chance 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.