BizzyD Posted November 15, 2013 Share Posted November 15, 2013 Hello, I am currently making a UCP, and I want the code to show Yes or No instead of 0 and 1 when a player is banned.Just asking if someone could show me a example script.Mysql name is Banned.Right now its just Account Locked: [banned]Thanks! Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted November 15, 2013 Share Posted November 15, 2013 What is your current code. All it should require is a simple if/else if($var == 0) { // Yes (banned) } else { // No (not banned) } Quote Link to comment Share on other sites More sharing options...
BizzyD Posted November 15, 2013 Author Share Posted November 15, 2013 Hey, Will try that! Right now its like this: <b>Account Locked:</b> [banned] Quote Link to comment Share on other sites More sharing options...
BizzyD Posted November 15, 2013 Author Share Posted November 15, 2013 New code is: <?php echo $row['Banned']; ?> Now it wont show anything Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted November 16, 2013 Share Posted November 16, 2013 posting one line of your code doesn't help anyone to help you. i could name 10-20 different reasons why the one line of code you have posted doesn't show anything. if you want actual help with your code, you will need to post all the relevant code needed to reproduce the problem. Quote Link to comment Share on other sites More sharing options...
waynew Posted November 16, 2013 Share Posted November 16, 2013 (edited) echo ($banned === 1) ? 'Yes' : 'No'; Edited November 16, 2013 by waynewex Quote Link to comment Share on other sites More sharing options...
BizzyD Posted November 16, 2013 Author Share Posted November 16, 2013 Sorry, Here is home.php <?php session_start(); if(!isset($_SESSION['LoggedIn'])) { header("Location: index.php"); } include 'tempfunctions.class.php'; $Username = $_SESSION['Username']; $mysqli = new mysqli("DELETED", "DELETED", "DELETED", "DELETED"); $Template = new Template; $results = $mysqli->query("SELECT * FROM playerdata WHERE username = '$Username'"); $Row = $results->fetch_array(MYSQLI_ASSOC); $result = mysql_query("SELECT * FROM `playerdata` WHERE `username` = '$Username'"); while($row = mysql_fetch_array($result)) { echo $row['Banned'] ? "Yes" : "No"; } foreach($Row as $Name=>$Value) { $Template->assign($Name, $Value); } $Template->loadpage('stats.php'); ?> And the echo code: <?php echo $row['Banned']; ?> Quote Link to comment Share on other sites More sharing options...
BizzyD Posted November 16, 2013 Author Share Posted November 16, 2013 (edited) Fixed it. Thanks for the help This did the trick: <?php echo ([Banned] === 1) ? 'Yes' : 'No'; ?> one more question, how do I do it, if its set to 0 it says none. But if its higher then 1, it display the number Edited November 16, 2013 by BizzyD 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.