Auto Generating Student Ids

Hi!! And Happy Valentine’s Day In Advance!:smiley:
I want to generate a student identity number after submitting the form.
The format is Institute Initial-Course Name Of Particular Student-Current Year-001 & so on.If I use following code, I get the Id, but how can I auto-increment it?And how can I put 00 before each id?

<?PHP
$my=mysql_connect("localhost","root","");
mysql_select_db("lab",$my);
$query=mysql_query("SELECT stud_master_initial, stud_master_cource, stud_master_batch FROM student_master");
while($row=mysql_fetch_array($query))
{
$ini=$row['stud_master_initial'];
$cource=$row['stud_master_cource'];
$batch=$row['stud_master_batch'];
$no= strtoupper($ini) . '-' . ($cource) . '-' .($batch) . '-' .???;
echo $no;
}
?>

Yeh.I want to store the id in database and also provide search option for this id.Means if user inserts the id like:LVP-BE-2010-001 he can see the information regarding this id.Do you mean that I can store the id in four different fields and just increment the last field?
But how can I search for this id afterward?Please guide me.

Thanks a lot webgypsy. I think this will solve my problem.
And yes.Thanks for the extra efforts you took to edit your post just to correct my spelling mistake!! I will keep it in mind next time. :slight_smile: