I have this chunk of code. It works, but I'm sure there is a simpler and more logical way of doing it. And just to save questions, $seriespart instead of $row["SeriesPart"] is specific because of previous code.
// normal titling convention is Number - Series - Series Part - Sermon
if ($row["Number"] && $row["Series"] && $row["SeriesPart"] && $row["Sermon"]) $title = $row["Number"]." - ".$row["Series"]." - Pt. ".$seriespart." - ".$row["Sermon"];
// but sometimes a series doesn't have sermon titles
else if ($row["Number"] && $row["Series"] && $row["SeriesPart"]) $title = $row["Number"]." - ".$row["Series"]." - Pt. ".$seriespart;
// series that are in process don't have product numbers
else if ($row["Series"] && $row["SeriesPart"] && $row["Sermon"]) $title = $row["Series"]." - Pt. ".$seriespart." - ".$row["Sermon"];
// but sometimes a series doesn't have sermon titles
else if ($row["Series"] && $row["SeriesPart"]) $title = $row["Series"]." - Pt. ".$seriespart;
// and we don't want product singles just showing a sermon title (it should say S74 - Title as a distinction from other oddball sermons)
// note the substr() as we want it to say S71 and not S0171
else if ($row["Number"] >= "0100" && $row["Number"] <= "0199") $title = "S".substr($row["Number"], 2)." - ".$row["Sermon"];
// just show the bloody sermon title already
else $title = $row["Sermon"];
We have a bunch of sermons. Those sermons are, usually, part of a series. If a series is finished, it will have a series number, series title, series part, and optionally sermon title, sermon part, subtitle, and subtitle part. If a series isn't finished, there won't be a series number. Sometimes, there is no sermon title. If it's not part of a series, then it can be an actual product unto itself. Other times, it's just an oddball sermon that isn't a part of anything.
Examples...
Made Healed (sermon only, not part of a series, oddball)
S45 - Sucker Or Sower? (single that is a product)
The Helper - Pt. 1 - Do You Need Help? (series in progress, no series number)
0513 - Harden Not Your Heart - Pt. 2 (completed series, no sermon title)
1101 - The Honor Of God - Pt. 11 - How God Honors Us - Pt. 5 - By Using Us - Pt. 3 (comleted series, sermon title - sermon part - subtitle - subtitle part)
Any ideas on how to clean up the code so I don't have to keep repeating the same information with if, else if, else?