This topic is locked
[SOLVED]

 Conditional Formatting all data values become the same

2/10/2018 9:03:15 AM
PHPRunner General questions
P
PaulM author

When I add conditional formatting all the statuses are displayed as Registered even though in the database they are different. The code I'm adding is:
if ($SPL_status='Registered')

{

$color="green";

}

else if ($SPL_status='Unregistered')

{

$color="red";

}

else {

$color="orange";

}

$value="<span style='color: " . $color . "'>" .$SPL_status . "</span>";

V
veca 2/10/2018

You have to use "==" as equal sign in PHP <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=84318&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />

P
PaulM author 2/10/2018

Thanks for the reply. Now the SPL_status isn't shown at all.
if ($SPL_status == 'Registered')

{

$color="green";

}

else if ($SPL_status == 'Unregistered')

{

$color="red";

}

else {

$color="orange";

}

$value="<span style='color: " . $color . "'>" .$SPL_status . "</span>";



You have to use "==" as equal sign in PHP <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=84319&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />

romaldus 2/10/2018

In "view as custom" you cannot use actual field name "spl_status". Use $value instead

romaldus 2/10/2018

Correct code:



if ($value == 'Registered')

{

$color="green";

}

else if ($value == 'Unregistered')

{

$color="red";

}

else {

$color="orange";

}

$value="<span style='color: " . $color . "'>" .$value. "</span>";
P
PaulM author 2/10/2018

Thank you, that now works perfect.



Correct code:



if ($value == 'Registered')

{

$color="green";

}

else if ($value == 'Unregistered')

{

$color="red";

}

else {

$color="orange";

}

$value="<span style='color: " . $color . "'>" .$value. "</span>";


P
PaulM author 2/12/2018

This is weird, its now stopped working and I get either red for Unregistererd or orange for everything else. It was working yesterday and I haven't made any changes.



Thank you, that now works perfect.