This topic is locked

Insert record or value if field field is NULL

4/21/2007 11:16:21 AM
PHPRunner General questions
S
spoilar author

I have a table (shipments), from which use the value from the field (shiptype) on my list page.
I was wondering if there was any way I could display the value of another field (linestat) that belongs to another table (orders) if the value in (shiptype) was empty (NULL).
I was thinking maybe if shiptype was NULL I could have it display a default value (Open).
I am just stumped at how to go about it.

S
spoilar author 4/22/2007

Got it.
I just entered
[codebox]if($value == NULL)

{

$value = "Open";

}[/codebox]
into the Custom "View As" setting on the Visual Editor tab.
That should work fine for now.

S
spoilar author 4/23/2007

Ok, scratch that. I figured out the right way. Maybe. I added this to the Edit query.
[codebox]IFNULL(`ship`.`shiptype`,`ord`.`linestat`) AS stat[/codebox]
I also used a JOIN.
That seems to get me exactly what I need. The true value from the linestat field.