php - MySQL datatype with many options -


i'm creating mysql table store user information. if 1 info user's graduation year, 1970~2014, best datatype this? want values give users options choose graduation year when sign up.
going use enum this. grdyr enum('70','71','72', ... '14'), myaql maual recommends not use numbers enum values. adding character grdyr enum('s70','s71','s72', ... 's14') solve problem?

also, if add more values later on, year 15, 16, , on students graduate each year, altering table each time way done? knowledge, seems way altering table sounds shouldn't do.

help please!

firstly, should use multiple tables , foreign keys insead of enum. should store year in 4 digit format, instead of 2 digits. because... if need add year 2070?

secondly, use datetime or date type of columns dates. or, use varchar, int, tinyint numbers yours (i still still prefer date types). not make table (or single column enum) containing user's graduation years. validate html/php code. make <select> particular option's , validate it.

html:

<select>     <option value="1970">1970</option>     <option value="1971">1971</option>     <option value="1972">1972</option>     ...     <option value="2013">2013</option>     <option value="2014">2014</option> </select> 

php:

$arraywithyears = array();  foreach($i = 1970; $i <= 2014; $i++) {     $arraywithyears[] = $i; }  if(in_array($isubmittedvalue, $arraywithyears)) {     // true } else {     // false } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -