Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mysql_hostname='localhost';
- $mysql_user='root';
- $mysql_password='';
- $mysql_database='a';
- $connect_db = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect to database");
- mysql_select_db($mysql_database, $connect_db ) or die("could not select database");
- //ambil 1 row dari table database, eg ambil izzat
- $sql = "SELECT * FROM biodata WHERE ast_id='1' ";
- $result=mysql_query($sql);
- $data = mysql_fetch_array($result);
- //tukar 1 kepada 001
- $number = $data['ast_id'];;
- $number = sprintf('%03d',$number);
- //tukar program kepada program code
- $program = $data['ast_program'];
- if($program == 'Diploma Akaun')
- {
- $program_code = 'C01';
- }
- else if ($program == 'Diploma Seni')
- {
- $program_code = 'C02';
- }
- else {}
- //date eg 16
- $date = date("y");
- //gabung jd no matric student
- $matric_num = 'Z'.$date.$program_code."(".$number.")";
- //update masuk dalam database, asalnya matrik no tinggal kosong, pahtu update gune line bawah ni
- $result = mysql_query("UPDATE biodata SET ast_matric='$matric_num' WHERE ast_id='1' ");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement