Lalu, untuk selectnya, karena di depannya pakai 0, gunakan fungsi sprintf()

Misalnya

$command = "SELECT `wilayah`, `counter` FROM `kode`;
$query = mysql_query($command);

$i = 0;
while($data = mysql_fetch_array($query)){
    $hasil[$i] = (sprintf("%02d",$data['wilayah'])."
".(sprintf("%03d",$data['counter']);
// atau $hasil[$i] = (string)((sprintf("%02d",$data['wilayah'])."
".(sprintf("%03d",$data['counter']));
// takutnya kalau pakai yang atas nggak keluar tipe string
    $i++;
}

LuckyGuy354
IT Beginner

http://www.wiwid.org || http://www.ragusa.co.id

----- Original Message -----
From: "LuckyGuy354" <[EMAIL PROTECTED]>


> 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);
>
> }



------------------------ 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/
 



Kirim email ke