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

  • Home
  • SEARCH
  • 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 8650751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:53:55+00:00 2026-06-12T13:53:55+00:00

I have a MySql table that stores the users state and city from a

  • 0

I have a MySql table that stores the users state and city from a list of states and cities. I specifically coded each state as their two letter shortened version (like WA for Washington and CA for California) and every city has the two letter abbreviation and the city name formated like this: Boulder Colorado would be CO-boulder and Salt Lake City, Utah would be UT-salt-lake-city as to avoid different states with same city name. The PHP inserts the value (UT-salt-lake-city) under the column City, but when I call the variable through PHP, it displays like this: Your location is: UT-salt-lake-city, Utah.
To solve this, I’ve been making this list of variables

    if ($city == "AL-auburn") { $city = "Auburn"; }
    else if ($city == "AL-birmingham") { $city = "Birmingham"; }
    else if ($city == "GA-columbus") { $city = "Columbus"; $state = "Georgia"; }
    else if ($city == "AL-dothan") { $city = "Dothan"; }
    else if ($city == "AL-florence") { $city = "Forence"; }
    else if ($city == "AL-muscle-shoals") { $city = "Muscle Shoals"; }
    else if ($city == "AL-gadsden-anniston") { $city = "Gadsden Anniston"; }
    else if ($city == "AL-huntsville") { $city = "Huntsville"; }
    else if ($city == "AL-decatur") { $city = "Decatur"; }
    else if ($city == "AL-mobile") { $city = "Mobile"; }
    else if ($city == "AL-montgomery") { $city = "Montgomery"; }
    else if ($city == "AL-tuscaloosa") { $city = "Tuscaloosa"; }

Is there a way I can shorten this process or at least call it from a separate file so I don’t have to copy/paste every time I want to call the location?

  • 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-12T13:53:57+00:00Added an answer on June 12, 2026 at 1:53 pm

    What about something like

    $name = 'UL-salt-lake-city';
    ucwords(str_replace("-"," ",substr($name, 3)));
    

    Converts to “Salt Lake City”

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

Sidebar

Related Questions

So I have this function that takes all the users from an MySql table
I have a table that stores scores from users of my game - what
I have a table that stores values each hour from a website based on
I have mysql table that has a column that stores xml as a string.
I have a Mysql table that stores dates in the format (YYYY-MM-DD HH:MM:SS). What
I have a table called Comments that stores messages between two users, and the
I have this table for users that stores their usernames and other data, thats
I have a mysql database that stores users that are online. Is there an
I have a table in mysql where it stores the messages between users. The
I have a table that stores user information in a table in a MySQL

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.