1

i need to use if statement inside my table the value of the row is "Released" but i want to show Pending on my html table. how can i achieve it. this is my current code. what's wrong with my if statement?

 if (strlen($row['signed']) == "Released") {
                                    echo "Pending";
                                    }
                                    else{
                                        echo $row['signed']; 
                                    }
4
  • 4
    strlen() returns the length of the argument, so it returns an integer. You're trying to compare an integer to a string, which always fails. Commented Mar 7, 2016 at 12:44
  • 1
    why you are using strlen function? try it with remove of strlen function. Commented Mar 7, 2016 at 12:44
  • First you read the use of strlen Commented Mar 7, 2016 at 12:44
  • what do you expect from strlen($row['signed']) ? Commented Mar 7, 2016 at 12:44

4 Answers 4

3

strlen checks for string length. first check either signed is set in the array and then check if value is equal

 if (isset($row['signed']) && $row['signed'] == "Released") {
                                    echo "Pending";
                                    }
                                    else{
                                        echo $row['signed']; 
                                    }
Sign up to request clarification or add additional context in comments.

Comments

3

strlen() returns the length of the argument, so it returns an integer. You can check if value is equals to the string which you want something like this:

if ($row['signed'] == "Released") {
   echo "Pending";
} else {
   echo "Released";
}

Comments

1

strlen() is used to count the length of the string, to check if it matches "Released", just use == to compare:

if ($row['signed'] == "Released") {
    echo "Pending";
} else {
    echo $row['signed']; 
}

To find out is $row['signed'] is set, just use isset():

if (isset($row['signed'])) {
    echo "Pending";
} else {
    echo $row['signed']; 
}

More information on isset(): http://php.net/manual/en/function.isset.php

More information on PHP operators: http://php.net/manual/en/language.operators.php

Comments

1

Try this:

if ($row['signed'] == "Released") {
   $value = "Pending";
} else {
   $value = "Released" 
}

And add <?php echo $value; ?> in your table

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.