Post
by johnjj » Wed Feb 03, 2010 11:33 am
Hello
Thank for you r support, this is what i wanted n came up with in the file product_form.tpl
<?PHP
$random_id_length =6;
$rnd_id = crypt(uniqid(rand(),001));
$rnd_id = strip_tags(stripslashes($rnd_id));
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
$rnd_id = substr($rnd_id,0,$random_id_length);
# DB settings
$mysql_server = 'localhost';
$mysql_user = '######';
$mysql_passwd = '#####';
$mysql_db = #######';
# Connect to database
$conn = mysql_connect($mysql_server, $mysql_user, $mysql_passwd);
if (!$conn)
die("Unable to connect to db server!");
# Select the db
mysql_select_db ($mysql_db, $conn) || die("Unable to select db $mysql_db");
$sL = "select count(*) from product";
$result = mysql_query($sL);
$details = mysql_fetch_array($result);
$new_cnt = $details[0] + 1;
$cnt_id = 'AA0000'.$new_cnt;
echo "<input type='text' name='model' readonly='readonly' value='$cnt_id'>";
?>