"; print ""; # ********************************************************** # 外部ファイル # ********************************************************** inc( "http://homepage2.nifty.com/lightbox/gen/db.php" ); $SQL = new DB( "mysql", "nsyCzZ3a", "nsyCzZ3a", "leopard" ); $Cond = ""; $str=''; $str.="select 社員コード \n ,氏名 \n ,フリガナ \n ,所属 "; $str.="\n ,case 性別 \n when 1 then '女性' \n when "; $str.="0 then '男性' \n end as 性別 \n ,作成日 \n ,更新日 "; $str.="\n ,case \n when 給与 < 1000 then \n 給与 "; $str.="\n when 給与 < 1000000 then \n concat( \n"; $str.="truncate(給与/1000,0),',',right(給与,3) "; $str.="\n ) \n when 給与 < 1000000000 then \n concat( "; $str.="\n truncate(給与/1000000,0),',' \n"; $str.=", right(concat('00',mod(truncate(給与/1000,0),1000)),3) "; $str.=",',' \n ,right(給与,3) \n ) \n end as 給与 "; $str.="\n ,手当 \n ,管理者 \n from 社員マスタ "; $Query .= $str; if ( $_GET['test'] == 1 ) { $Cond .= " where 性別 = 1"; } if ( $_GET['test'] == 0 ) { $Cond .= " where 性別 = 0"; } if ( $_GET['name'] != "" ) { if ( $Cond != "" ) { $Cond .= " and "; } else { $Cond .= " where "; } // $_GET['name'] = urldecode($_GET['name']); $Cond .= " 氏名 like '%{$_GET['name']}%'"; } file_put_contents( "./log.txt", print_r($_GET,true) . "\n" . $Query . $Cond ); $Column = $SQL->QueryEx( $Query . $Cond ); while( $Column ) { print el(0,"row"); for( $i = 0; $i < 11; $i++ ) { print elset(1,"COL_" . ($i+1), $Column[$i] ); } print el(0,"/row"); print "\n"; $Column = $SQL->QueryEx( ); } # ********************************************************** # 接続解除 # ********************************************************** $SQL->Close(); print ""; # ********************************************************** # URL によるコード取得 # ********************************************************** function inc( $path ) { $inc = @file( $path ); array_shift($inc); array_pop($inc); $GLOBALS['inc_eval_txt'] = implode( "", $inc ); eval($GLOBALS['inc_eval_txt']); } # ********************************************************** # 要素とデータ # ********************************************************** function el( $lv, $ename ) { $tab = ""; for( $i = 0; $i < $lv; $i++ ) { $tab .= "\t"; } return "$tab<$ename>\n"; } # ********************************************************** # 要素 # ********************************************************** function elset( $lv, $ename, $edata ) { $tab = ""; for( $i = 0; $i < $lv; $i++ ) { $tab .= "\t"; } return "$tab<$ename>$edata\n"; } ?>