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

Link to comment
Share on other sites

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... Edited by requinix
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.