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

$result = mysql_query("SELECT articleNo FROM apacearticle ORDER BY articleNo DESC LIMIT 1";


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

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

if($index < 10)
{
	$index = "A0000".$index;
}
else if($index < 100)
{
	$index = "A000".$index;
}
else if ($index < 1000)
{
	$index = "A00".$index;
}
else if($index < 1000)
{
	$index = "A0".$index;
}
else if ($index < 10000)
{
	$index = "A".$index;
}
else
{
	$index = "Article field is full!";
}

?>