Gunawan

Mhon penjelasan

May 13th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. function auto_number($field,$table,$key,$Parse,$Digit_Count){
  4. $NOL="0";
  5. $sql = mysql_query("Select $field from $table where $key like '$Parse%' order by $key DESC");
  6. $counter=2;
  7. if(mysql_num_rows($sql)==0)
  8. {
  9. while($counter < $Digit_Count)
  10. {
  11. $NOL="0".$this->NOL;
  12. $counter++;
  13. }
  14. return $Parse.$this->NOL."1";
  15. }
  16. else
  17. {
  18. $R = mysql_fetch_array($sql);
  19. $K = sprintf("%d",substr($R[0],-$Digit_Count));
  20. $K = $K + 1;
  21. $L = $K;
  22. while(strlen($L)!=$Digit_Count)
  23. {
  24. $L = $NOL.$L;
  25. }
  26.  
  27. return $Parse.$L;
  28. }
  29. }
  30.  
  31. echo auto_number('nis','mahasiswa','nis',$kdFakultas.$kdJurusan.$thnMasuk,$jmlUrut);
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment