Jump to content

Help with IF statement


Texan78

Recommended Posts

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 by Texan78
Link to comment
Share on other sites

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 by lovephp
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

$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.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.