<?php
include("connect.php");

$result = mysql_query("SELECT leaveNo FROM staffleave ORDER BY leaveNo DESC LIMIT 1");


$row = mysql_fetch_array($result);

$leaveNo = $row["leaveNo"];
list($one[0],$one[1]) = split('L',$leaveNo);

$index = ++$one[1];
$num = $index;

if($index < 10)
{
	$index = "L0000".$index;
}
else if($index < 100)
{
	$index = "L000".$index;
}
else if ($index < 1000)
{
	$index = "L00".$index;
}
else if($index < 1000)
{
	$index = "L0".$index;
}
else if ($index < 10000)
{
	$index = "L".$index;
}
else
{
	$index = "Leave Form field is full!";
}

?>