Int fields won't store a leading zero in cases other than zero, since that's not what integer numbers are supposed to be. However, since the student id is never actually going to be the subject of any mathematical calculations, the fact that it is actually a number is surely coincidental. So, surely the easiest option would be to change the field type to varchar(9). When posting values from forms, you could protect leading zeros by force the variable recieving the posted value to accept it as a string, by casting it as such:
$student_id = (string)$_POST['student_id'];
Alternatively, if student_id is actually a zero-padded string containing a numeric value, it is probably better to use a preformatted string function such as printf.
Let us know how you get on.
Take it easy,
Dan
|