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

$result = mysql_query("SELECT cartNo FROM cart ORDER BY cartNo DESC LIMIT 1");
$row = mysql_fetch_array($result);
$cartNo = $row["cartNo"];
list($one[0],$one[1]) = split('CT',$cartNo);

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

if($index < 10)
{
	$index = "CT0000".$index;
}
else if($index < 100)
{
	$index = "CT000".$index;
}
else if ($index < 1000)
{
	$index = "CT00".$index;
}
else if($index < 1000)
{
	$index = "CT0".$index;
}
else if ($index < 10000)
{
	$index = "CT".$index;
}
else
{
	$index = "Your CODE field is full!";
}

?>