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

$result = mysql_query("SELECT slipNo FROM salaryslip ORDER BY slipNo DESC LIMIT 1");


$row = mysql_fetch_array($result);
$slipNo = $row["slipNo"];
list($one[0],$one[1]) = split('S',$slipNo);

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

if($index < 10)
{
	$index = "S0000".$index;
}
else if($index < 100)
{
	$index = "S000".$index;
}
else if ($index < 1000)
{
	$index = "S00".$index;
}
else if($index < 1000)
{
	$index = "S0".$index;
}
else if ($index < 10000)
{
	$index = "S".$index;
}
else
{
	$index = "Salary slip field is full!";
}

?>