Jump to content

NULL Fields and IF/Else On Join Won't exclude


TecTao

Recommended Posts

A select query I've written joins three tables.  The query works fine, pulling up a users table, a table for specials advertising that are entered by members, a and a third table the identivies members who have joined a customer  application.

 

A page displays listing all the entries who have joined the customer application, their names, address, etc display but if they have not set up their special advertising, then the fields for that table display NULL.

 

I have tried an If and an ifelse to not display text (you can see in the code the HTML Hours of Operation: and Specials:).  Thee field I am using to differentiate is "m_primeID", it is an intiger field.  The if statement I've written is follows.

	if( $row["$m_primeID"] == 'NULL' )
	{
		$company .= "";
	}
	elseif( $row["$m_primeID"] <> 'NULL'  )
		{
	$company .= "<b>Hours of Operation:</b><br>" . ($row["m_coupon_title"]) . "<br /><br />\n";
	$company .= "<b>Special:</b><br>" .($row["m_coupon_desc"]) . "<br /><br />\n";
		}

Here is a screen shot of part of the joined tables.

 

 

 

This screen shot show the Null on the joined tables that don't have customer advertising set up.

 

Any Ideas

post-18267-0-28098000-1412277440_thumb.jpg

The value isn't actually the string "NULL". It's the value null itself.

 

Forget the elseif and just do

	if( $row["$m_primeID"] )
	{
	$company .= "<b>Hours of Operation:</b><br>" . ($row["m_coupon_title"]) . "<br /><br />\n";
	$company .= "<b>Special:</b><br>" .($row["m_coupon_desc"]) . "<br /><br />\n";
		}
[edit] And I doubt you mean to use a variable $m_primeID...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.