Hi I'm new in PHP need some help, i want to generate auto registration code like this (e.g: 0001, 0002, ..) form data base if available in database auto plus one in last number if not start from 0000 it go at 9999 and stop
my sql table as
id | regisCode | title
query is
$query = mysql_query("Select * from accounts");
$result = mysql_num_rows($query);
if ($result > 0){
$row = mysql_fetch_array ($result);
} else{
$new = 0000;
}
$account = substr('0000', 1);
$faccount = 1+$account;
echo "<h1>". $faccount ."</h1>";
sorry for poor english