Advertisement
ronikuchan

kode unik (PHP)

Dec 2nd, 2019
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. //mencari kode terakhir
  2.         $kd_reg='INV';
  3.         $cari_kode=mysql_query("select tbayar_no_bukti from tb_transaksi_pembayaran
  4.             JOIN tb_beban ON tb_transaksi_pembayaran.tbayar_beban_sud=tb_beban.id
  5.             order by tb_transaksi_pembayaran.id DESC");
  6.         $tm_cari=mysql_fetch_array($cari_kode);
  7.         $kode=substr($tm_cari['tbayar_no_bukti'],3);
  8.         $tambah=$kode + 1;
  9.         if($tambah<10)
  10.         {
  11.             $tbayar_no_bukti=$kd_reg.'00000'.$tambah;
  12.         }
  13.         elseif($tambah>=10 AND $tambah<100)
  14.         {
  15.             $tbayar_no_bukti=$kd_reg.'0000'.$tambah;
  16.         }
  17.         elseif($tambah>=100 AND $tambah<1000)
  18.         {
  19.             $tbayar_no_bukti=$kd_reg.'000'.$tambah;
  20.         }
  21.         elseif($tambah>=1000 AND $tambah<10000)
  22.         {
  23.             $tbayar_no_bukti=$kd_reg.'00'.$tambah;
  24.         }
  25.         elseif($tambah>=10000 AND $tambah<100000)
  26.         {
  27.             $tbayar_no_bukti=$kd_reg.'0'.$tambah;
  28.         }
  29.         elseif($tambah>=100000)
  30.         {
  31.             $tbayar_no_bukti=$kd_reg.$tambah;
  32.         }
  33.         //akhir mencari kode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement