Last active
December 23, 2018 01:58
-
-
Save rizalrizal/896142b99eefd2ef67b99803617e343b to your computer and use it in GitHub Desktop.
Penomoran Otomatis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //cari id terakhir ditanggal hari ini | |
| $query1 = "SELECT max(no_pengiriman) as maxID FROM tbl_pengiriman WHERE no_pengiriman LIKE '$today%'"; | |
| $hasil = $mysqli->query($query1); | |
| $data = mysqli_fetch_array($hasil); | |
| $idMax = $data['maxID']; | |
| //setelah membaca id terakhir, lanjut mencari nomor urut id dari id terakhir | |
| $NoUrut = (int) substr($idMax, 8, 4); // ambil 4 digit dimulai dari index ke 8 | |
| $NoUrut++; //nomor urut +1 | |
| //setelah ketemu id terakhir lanjut membuat id baru dengan format sbb: | |
| $NewID = $today .sprintf('%04s', $NoUrut); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment