Vote count:
0
I'm developing application that need unique code such as: TS001, TS0002, TS003
I have PHP source code for autonumber like this:
function autoNumber($tabel, $kolom, $lebar=0, $awalan) {
$q = mysql_query("SELECT $kolom FROM $tabel ORDER BY $kolom DESC LIMIT 1");
$jum = mysql_num_rows($q);
if($jum == 0) {
$nomor = 1;
} else {
$data = mysql_fetch_array($q);
$nomor = intval(substr($data[0],strlen($awalan))) + 1;
}
if($lebar > 0) {
$angka = $awalan.str_pad($nomor,$lebar,"0",STR_PAD_LEFT);
} else {
$angka = $awalan.$nomor;
}
return $angka;
}
But i have a problem when i try it on Codeigniter.
asked 42 secs ago
Codeigniter: How to make Autonumber
Aucun commentaire:
Enregistrer un commentaire