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

$result = mysql_query("SELECT doNo FROM deliveryorder ORDER BY doNo DESC LIMIT 1");


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

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

if($index < 10)
{
	$index = "DO0000".$index;
}
else if($index < 100)
{
	$index = "DO000".$index;
}
else if ($index < 1000)
{
	$index = "DO00".$index;
}
else if($index < 1000)
{
	$index = "DO0".$index;
}
else if ($index < 10000)
{
	$index = "DO".$index;
}
else
{
	$index = "Delivery Order field is full!";
}

?>