Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2. $mysql_hostname='localhost';
  3. $mysql_user='root';
  4. $mysql_password='';
  5. $mysql_database='a';
  6.  
  7. $connect_db = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect to database");
  8. mysql_select_db($mysql_database, $connect_db ) or die("could not select database");
  9.  
  10.  
  11. //ambil 1 row dari table database, eg ambil izzat
  12. $sql = "SELECT * FROM biodata WHERE ast_id='1' ";
  13. $result=mysql_query($sql);
  14. $data = mysql_fetch_array($result);
  15.  
  16.  
  17. //tukar 1 kepada 001
  18. $number = $data['ast_id'];;
  19. $number = sprintf('%03d',$number);
  20.  
  21.  
  22. //tukar program kepada program code
  23. $program = $data['ast_program'];
  24.  
  25. if($program == 'Diploma Akaun')
  26. {
  27.   $program_code = 'C01';
  28. }
  29.  
  30. else if ($program == 'Diploma Seni')
  31. {
  32.   $program_code = 'C02';
  33. }
  34.  
  35. else {}
  36.  
  37.  
  38. //date eg 16
  39. $date = date("y");
  40.  
  41. //gabung jd no matric student
  42. $matric_num = 'Z'.$date.$program_code."(".$number.")";
  43.  
  44.  
  45. //update masuk dalam database, asalnya matrik no tinggal kosong, pahtu update gune line bawah  ni
  46. $result = mysql_query("UPDATE biodata SET ast_matric='$matric_num'  WHERE ast_id='1' ");
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement