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)
?>