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

//$query = "SELECT receiptNo FROM receipt ORDER BY receiptNo DESC LIMIT 1";
//$result = $db->query($query);

$result =  mysql_query("SELECT receiptNo FROM receipt ORDER BY receiptNo DESC LIMIT 1");

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

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

if($index < 10)
{
	$index = "B00000".$index;
}
else if($index < 100)
{
	$index = "B0000".$index;
}
else if ($index < 1000)
{
	$index = "B000".$index;
}
else if($index < 1000)
{
	$index = "B00".$index;
}
else if ($index < 10000)
{
	$index = "B0".$index;
}else if ($index < 100000)
{
	$index = "B".$index;
}
else
{
	$index = "Cashier Bill field is full!";
}

?>