Buat dua buah field, satu untuk kode wilayah, satu lagi untuk counter.
CREATE TABLE `kode` (
`wilayah` int(10) unsigned NOT NULL default '0',
`counter` int(10) unsigned NOT NULL default '0',
`keterangan` varchar(200) default '',
PRIMARY KEY (`wilayah``,`counter`)
);
kalau mau masukin data, supaya counter bertambah otomatis:
if(isset($_POST['wilayah'])){ // misalnya diambil dari form
$command = "SELECT `counter` FROM `kode` where `wilayah` =
'".$_POST['wilayah']."' ORDER BY `counter` DESC LIMIT 1;
$query = mysql_query($command);
$data = mysql_fetch_row($query);
$max = ++$data[0];
$command = "INSERT INTO `kode` SET `wilayah` = '".$_POST['wilayah']."',
`counter` = '".$max."';
$query = mysql_query($command);
}
LuckyGuy354
IT Beginner
http://www.wiwid.org || http://www.ragusa.co.id
----- Original Message -----
From: "Dian Firdausiah" <[EMAIL PROTECTED]>
> Tolong bantuin dong..
> gimana caranya klo mau buat kode dengan format 02 001,
> 02nya diambil dari kode wilayah yg udah di input, trus 001 nya itu
> akan bertambah secara otomatis(semacam counter), thanks banget yach
------------------------ Yahoo! Groups Sponsor --------------------~-->
Clean water saves lives. Help make water safe for our children.
http://us.click.yahoo.com/CHhStB/VREMAA/E2hLAA/BRUplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/mailplus/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/