Texan78 Posted August 4, 2016 Share Posted August 4, 2016 (edited) I am sure I am having a brain fart and just need some extra eyes as I am overlooking something. I am trying to do a very simple IF statement but, for some reason it is not working. Here is what I have. <?php if ($status[1] < true) { echo $location[1]; } ?> I have also tried it this way and it won't work ether. <?php if ($status[1] < true) echo $location[1]; ?> I am using that same $status variable in a different ELSE/IF statement and it works fine but, for some reason it is not working for this. Logic behind how this is suppose to work. This is pulling from a database and I can echo the $location variable just fine so I know that is working. $status also comes from the database with a value of ether true or false. So what I am trying to do is if the $status value is true then echo $location which is just the location which is in the DB. For some odd reason which I am sure it is something simple I am overlooking, it is not working. If anyone could offer my tired eyes some input that would be greatly welcomed. -Thanks Edited August 4, 2016 by Texan78 Quote Link to comment Share on other sites More sharing options...
Texan78 Posted August 4, 2016 Author Share Posted August 4, 2016 Well, come to find out this isn't working after all. <?php if ($status[2] < true) { echo "<span class='label label-success'>LIVE</span>"; } else { echo "<span class='label label-important'>OFFLINE</span>"; } ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted August 4, 2016 Share Posted August 4, 2016 $status[2] lolwat Quote Link to comment Share on other sites More sharing options...
Texan78 Posted August 4, 2016 Author Share Posted August 4, 2016 $status[2] < truelolwat Huh? I am sorry, I only speak English. Quote Link to comment Share on other sites More sharing options...
lovephp Posted August 4, 2016 Share Posted August 4, 2016 (edited) What is true false doing in your if else statement? How is the if statement suppose to know if status[1] is less than true hahaha wtf man assign some value to the true like $true = 1; If($status[1] < $true){ echo 'bla bla'; } Or something this it has to be $status[1] = 'true'; If($status[1] == 'true'){ echo 'bla bla'; } Edited August 4, 2016 by lovephp Quote Link to comment Share on other sites More sharing options...
Texan78 Posted August 4, 2016 Author Share Posted August 4, 2016 What is true false doing in your if else statement? How is the if statement suppose to know if status[1] is less than true hahaha wtf man assign some value to the true like $true = 1; If($status[1] < $true){ echo 'bla bla'; } I appreciate your response but, I do not appreciate the sarcastic remarks I am receiving when it is not deserving. I do not work with PHP but a couple times a year if that. So I could do without the ridicule. A much better approach instead of demeaning people would be to guide them. That is why this is a community support forum. For those looking for support on issues in which they are stuck on. Not to be laughed at for the lack of proficient PHP knowledge. As I stated in my OP.... $status also comes from the database with a value of ether true or false. Therefore if $status = true then echo blah blah blah. If I am doing this incorrectly could someone please provide me with a better and correct approach as I am only going off memory and my searches are coming up empty. -Thanks! Quote Link to comment Share on other sites More sharing options...
lovephp Posted August 4, 2016 Share Posted August 4, 2016 Share everything including the fetching from db Quote Link to comment Share on other sites More sharing options...
lovephp Posted August 4, 2016 Share Posted August 4, 2016 But mate i already showed you if $status[1] == 'true' why you trying to compare less than etc? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 4, 2016 Share Posted August 4, 2016 $status also comes from the database with a value of ether true or false. I doubt that, because database systems like MySQL cannot store true or false. So what does the variable really contain? An integer like 0 and 1? A string like “true” and “false”? Something else? If you don't know, var_dump() will tell you: var_dump($status); Post the output here. I appreciate your response but, I do not appreciate the sarcastic remarks I am receiving when it is not deserving. You already said that you're probably having a brainfart, so why get pissed off when somebody points out the exact problem? Asking if a condition is “less than fulfilled” is just an odd way off thinking. Nobody made fun of your programming skills. 1 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.