MMMDI
03-28-2004, 04:11 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!
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!