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 838561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:19:28+00:00 2026-05-15T05:19:28+00:00

Good Afternoon, I am trying to assign some variables to a listing which has

  • 0

Good Afternoon,

I am trying to assign some variables to a listing which has a main category and a subcategory. This works fine for most of the variables, however in each sub category there are some fields which are other.

ie
Main Category 1 has sub category database, development and other
Main Category 2 has sub category email, internet and other
Main Category 3 has sub category graphics and other.

So my first case statement is as follows which works fine.

switch ($main_cat)
 {
    case "Main Category 1":
      $main="79";
        break;
    case "Main Category 2":
      $main="83";
        break;
    case "Main Category 3":
      $main="87";
        break;
}

However I am struggling as to how to handle other.

This stops the whole page loading with no error message

switch ($second_cat)
 {
    case "Database":
      $second="145";
        break;
    case "Development":
      $second="146";
        break;
    case "Other":
      if ($main_cat) == 'Main Category 1'  { $second="147";}
       break;
}

This doesn’t work at all, second is not changed.

switch ($second_cat)
 {
    case "Database":
      $second="145";
        break;
    case "Development":
      $second="146";
        break;
    case "Other":
switch ($main_cat)
{
case "Main Category 1":
      $second="147";
        break;
}
}
  • 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-05-15T05:19:29+00:00Added an answer on May 15, 2026 at 5:19 am

    Badly formed if statement:

    if ($main_cat) == 'Main Category 1'  { $second="147";}
    

    should be:

    if ($main_cat == 'Main Category 1')  { $second="147";}
    

    Also, you should put error_reporting(E_ALL); at the top of your script for debugging purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good afternoon, I've run into some issues trying to combine HTTP caching with Rack::Cache
Good afternoon, I am trying to use CASE like in this question to transpose
Good afternoon I'm facing a trouble, trying to figure out how to use this
I've spent a good while this afternoon trying to implement the deserialization of JSON
Good afternoon I'm hoping this is going to be nice and a simple f**k
Good Afternoon, A customer has provided me with a spreadsheet file his team uses
Good afternoon, I created an Excel .xla addin for Excel 2002. This weird behavior
Good Afternoon, I have a html aspx page that has many many div elements.
Good Afternoon, I'm currently trying to build something incredibly simple inside of the Google
Good Afternoon, I am trying to get these results into arrays in PHP so

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.