Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Roll Number Generation..

    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..
    PHP Code:
    $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??

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,337
    Thanks
    13
    Thanked 348 Times in 344 Posts
    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.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •