Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7896629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:56:36+00:00 2026-06-03T07:56:36+00:00

I have this chunk of code. It works, but I’m sure there is a

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:56:38+00:00Added an answer on June 3, 2026 at 7:56 am

    I think this will do what you want:

    $parts = array();
    if ($row["Number"] && ($row["Number"] < "Music01" || $row["Number"] > "Music99"))
    {
        if ($row["Number"] >= "0100" && $row["Number"] <= "0199") $parts[] = "S". substr($row["Number"], 2);
        else $parts[] = $row["Number"];
    }
    
    if ($row["Series"]) $parts[] = $row["Series"];
    if ($row["SeriesPart"]) $parts[] = "Pt. $seriespart";
    if ($row["Sermon"]) $parts[] = $row["Sermon"];
    
    $title = implode(" - ", $parts);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a chunk of code like this: .hover( function () { hoverState($(#navbar
I have trouble understanding this chunk of code: let sieve (p:xs) = p :
So i have this code that works perfectly without the 'file attachment' and sends
We have a chunk of code something like this // semi-pseudo code def result
I'm not sure what is happening. I have this code: `case (XMLREADER::ELEMENT): $node_type =
I have this chunk of code which is placed in accelerometer: didAccelerate which changes
I'm using node.js but I have a feeling this isn't necessarily related to just
I have this chunk of javascript that's kind of hacked around from http://www.developphp.com/view.php?tid=1248 and
I have this string containing a large chunk of html and am trying to
I have been having an ongoing fight with this email setup. The code below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.