PDA

View Full Version : Different rules for NULL / NOT NULL


MMMDI
03-28-2004, 03:58 AM
I'm setting up a movies review site, and having a bit of a problem with the movie data part.

When entering the movie information, each movie is assigned up to 2 directors. These are saved in the fields "director" and "director2". Most movies only have 1 director, so the director2 field would be set to null. This brings the problem....

If a movie has one director, the info should be parsed out on the page as:
Director: {DIRECTOR}
However, if the movie has 2 directors, it should be:
Director: {DIRECTOR} & {DIRECTOR2}

The closest I've been able to get to a usable solution is changing the array, ie:

"DIRECTOR" => $data['director'],
"DIRECTOR2" => " & ".$data['director2'],

However, this parses out as:

Director: {DIRECTOR} &
or
Director: {DIRECTOR} & {DIRECTOR2}


Basically, I want the & to be used if there is two directors, and not used if there's only one.

On another board, a user told me to try this, but I get parse errors on the "if" line, and I think he was getting a bit sick of me bugging him, heh....

$directors = array($data['director']);
if (!empty($data['director2'])) {
$directors[] = $data['director2'];
}

..and in the array:
"DIRECTORS" => implode(" & ",$directors),

Any help would be MUCH appreciated.... thanks!

This would be better off in the PHP forum... whoops, silly n00b me. A mod should delete this.

raf
03-28-2004, 11:16 AM
Continued here:

http://www.codingforums.com/showthread.php?s=&threadid=35902