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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:39:43+00:00 2026-05-12T11:39:43+00:00

I am trying to fix a project that someone else coded, it is a

  • 0

I am trying to fix a project that someone else coded, it is a mess!

On an edit user profile page they have something like this below which will list all available radio select boxes for the options a user can select for there education level, this is just 1 item, there is many items like it so based on the answers here, I can apply it to many other features on this code.

They used an array for many profile fields, it would store possible answers, A user can only choose 1 answer though in this case. So for education, there is 7 possible answers and a number corresponding with it’s number in the array is stored in a mysql DB, they store this 1 number as a varchar 255 length which can’t be good.

Should I store it as a varchar with 1 for length or use enum and list the 7 options, or something else?

Education

<?PHP
// Array of possible education profile selections
$arr_education[1]="No Answer";
$arr_education[2]="High school";
$arr_education[3]="Some college";
$arr_education[4]="In college";
$arr_education[5]="College graduate";
$arr_education[6]="Grad / professional school";
$arr_education[7]="Post grad";

// shows the array above as checkboxes on a form
foreach($arr_education as $ind=>$val) {  
    echo '<input type="radio" name="education" value="' .$ind. '" ' if($education==$ind){ echo "checked";}. '>' .$val. '<br>';
}



//on a users profile page there would be something like this
$education = 7; // seven would be Post Grad from our array above
echo $arr_education[$education]

//Now here is the mysql table, they chose to use a varchar(255) which seems retarded, using the above code, the max result would be 1 charachter long
education   varchar(255)

?>
  • 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-12T11:39:43+00:00Added an answer on May 12, 2026 at 11:39 am

    If this was a new project, I’d recommend using ENUM. It’s space efficient (it’s actually stored on 1 byte) and simple to use. However, if you have to support legacy code then I’d recommend sticking to raw numbers and change that column into a TINYINT.

    Additionally, I’d recommend replacing the numbers in your PHP source code with constants, so that you don’t have to guess what the code does. For example:

    define('EDU_NO_ANSWER', 0);
    define('EDU_HIGH_SCHOOL', 1);
    define('EDU_SOME_COLLEGE', 2);
    // etc...
    
    if ($education >= EDU_SOME_COLLEGE)
    {
        // student went to college, but you didn't need that
        // comment to know that
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That totally depends on your server configuration so your only… May 12, 2026 at 5:31 pm
  • Editorial Team
    Editorial Team added an answer Where is your skinHeight and skinWidth being set? Typically, degrafa… May 12, 2026 at 5:31 pm
  • Editorial Team
    Editorial Team added an answer Nice, I was wrong.. I found the problem. First use… May 12, 2026 at 5:31 pm

Related Questions

In the installation documentation to RoR it mentions that there are many limitations to
I'm currently about two-and-a-half weeks in to my first ASP.Net MVC application, and so
I have a CC.NET project configured to call a common NAnt build file, which
I am trying to setup a TFS Build, and am having trouble getting my

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.