Advertisement
justhrun

historymonthly.php

Oct 15th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. #!/usr/local/bin/php
  2. <?php
  3.     $bulan = date('n-Y');
  4.     $arrlike = array("f.%.o", "c.%", "f.%");
  5.     $arrcode = array("OLT", "SC", "SCF");
  6.    
  7.     include('konek34iqp.php');      // $con34
  8.     include('konek50iqp.php');      // $con50
  9.     // bantai dulu too old history
  10.     $query = "delete from jlh_total_monthly where tmstmp < date_sub(now(), interval 2 year)";
  11.     mysql_query($query,$con34);
  12.    
  13.     for($i=0;$i<count($arrcode);$i++) {
  14.         $like = $arrlike[$i];
  15.         $code = $arrcode[$i];
  16.         $query = "SELECT iqp_sc.wks as total,iqp_sc.user_id as lokasi,iqp_sc.status FROM iqp_user,iqp_sc
  17.                 where iqp_user.user_id=iqp_sc.user_id and iqp_user.sctyp='S' and iqp_user.user_id  like '$like'  
  18.                 order by iqp_user.user_id";
  19.         $result = mysql_query($query,$con50);
  20.         while( $data=mysql_fetch_array($result) ) {
  21.             $sum= $data['total'];
  22.             $status= $data['status'];
  23.             $lokasi= $data['lokasi'];
  24.             $query = "INSERT INTO jlhtotal_monthly VALUES (null,'$bulan','$code', '$sum','$lokasi','$status', 'system', NOW())";
  25.             mysql_query($query,$con34);
  26.         }
  27.         mysql_free_result($result);
  28.     }
  29.     mysql_close($con50);
  30.     mysql_close($con34);
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement