...

View Full Version : Roll Number Generation..



havish
11-07-2012, 09:47 AM
I have a student registration page where all the details like name, father name, dob, address etc would be taken. It also has admission number column, class column and roll number. Admission number is self explanatory.. and this is unique number. The class column is to which class the student is getting admitted. The classes are from Kindergarten to 10th standard.. and each student will have a roll number.. What I want to do is automate the task by generating admission numbers and roll numbers.. Admission number generating is done. For this I have first queried the db for admission number column and gave the order by clause..

$e = mysql_fetch_array(mysql_query("select * from student ORDER BY student_adm_no DESC"));
$f = $e['student_adm_no'] + 1;
echo '<input type="text" name="adm_no" id="adm_no" placeholder="Admission Number" class="validate[required, custom[admission]] text-input" value="'.$f.'" />$e = mysql_fetch_array(mysql_query("select * from student ORDER BY student_adm_no DESC"));
$f = $e['student_adm_no'] + 1;
echo '<input type="text" name="adm_no" id="adm_no" placeholder="Admission Number" class="validate[required, custom[admission]] text-input" value="'.$f.'" />
So always it queries the db and increments the admission number by 1.. pretty easy. But roll number generation is giving a problem. Not getting an idea how to implement. I have a dropdown in my registration page for selecting class. So based on the class selected by user roll number should be generated. And roll number field is not unique because in every class the roll numbers would start from 1 and go upto 100 based on strength. Any solution??

Dormilich
11-08-2012, 07:16 AM
1) you can see from the code highlighting, that something went wrong in writing.

2) why not use AUTO_INCREMENT ? makes that PHP code completely superfluous.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum