Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AgungPambudi/31c2a1a8aa265fdd353090f10e839860 to your computer and use it in GitHub Desktop.
Save AgungPambudi/31c2a1a8aa265fdd353090f10e839860 to your computer and use it in GitHub Desktop.
php script 'FOR logic' to looping table names and store in array
<?php
/*
| title : for_logic_to_looping_table_name_and_strore_in_array.php
| description : php script for logic to looping tablenames and store in array.
| author : Agung Pambudi
| website : http://agungpambudi.com
| email : mail@agungpambudi.com
| _ _ _
| ___ ___ _ _ ___ ___ ___ ___ _____| |_ _ _ _| |_| ___ ___ _____
| | .'| . | | | | . | . | .'| | . | | | . | |_| _| . | |
| |__,|_ |___|_|_|_ | _|__,|_|_|_|___|___|___|_|_|___|___|_|_|_|
| |___| |___|_|
|
*/
date_default_timezone_set("Asia/Jakarta");
$db_host = "";
$db_username = "";
$db_password = "";
for($i = (int)$d; $i <= (int)$d1; $i++){
$tablename = "pr_" . substr($y,2,2) . $m . (($i < 10) ? "0".$i : $i);
$vardate = "$y-$m-" . (($i < 10) ? "0".$i : $i);
$querysql = mysql_query("select toko, sum(qty) as qty,sum(gross) as gross, docno from $tablename where rtype <> 'L' and `div` between '01' and '29' group by toko, tglpb, docno", $dbconnection);
echo mysql_error();
while($rs = mysql_fetch_array($querysql)){
$arr_data_stored[$rs['toko']][$vardate] = $rs;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment