2013年4月18日 星期四

TCPDF分頁

$page=1;
$row=1;
$page_count=20;//每頁筆數
$total         //總筆數

while($all=$xoopsDB->fetchArray($result)){

  # -------- 頁首 -------------------------------------------------------
  if($row==1 or ($row%(($page-1)*$page_count+1)==0 and $row>$page_count)){ 
    $pdf->AddPage(); //新增頁面
    $main="<table><tr><th></th></tr>";
  }
  #----------body ----------------------
   $main.="<tr><td></td></tr>"; 
  #--------- 頁尾 ------------------------
  if($row==$total or $row%($page_count)==0){
   $main.="</table>";
   $pdf->writeHTML($main, true, false, false, false, '');
   $page++; #頁數
   $main="";#內容
  }
  $row++;
}

2013年3月29日 星期五

XOOPS與getdate()關係

範例

#---------------------------------------------------------------------
$time=xoops_getUserTimestamp(time()); # xoops 使用者時間 

1364583916
#---------------------------------------------------------------------
$today  = getdate($time );  # 格式化日期(xoops 使用者時間) 顯示畫面 
 
Array ( 
[seconds] => 16 
[minutes] => 5 
[hours] => 19 
[mday] => 29 
[wday] => 5 
[mon] => 3 
[year] => 2013 
[yday] => 87 
[weekday] => Friday 
[month] => March 
[0] => 1364583916 ) 
#---------------------------------------------------------------------

$today1 = getdate(); # 格式化日期(主機時間)

Array ( 
[seconds] => 16 
[minutes] => 5 
[hours] => 11 
[mday] => 29 
[wday] => 5 
[mon] => 3 
[year] => 2013 
[yday] => 87 
[weekday] => Friday 
[month] => March 
[0] => 1364555116 ) 

#---------------------------------------------------------------------
$today2 = getdate(userTimeToServerTime($time)); 
# 格式化日期(將xoops 使用者時間,還原成主機時間) 儲存進資料庫

Array ( 
[seconds] => 16 
[minutes] => 5 
[hours] => 11 
[mday] => 29 
[wday] => 5 
[mon] => 3 
[year] => 2013 
[yday] => 87 
[weekday] => Friday 
[month] => March 
[0] => 1364555116 ) 
#---------------------------------------------------------------------

 

2013年3月13日 星期三

取得選定群組的會員名單

取得選定群組的會員名單
foreach ($groups  as $k => $group){
    if($k==0){
      $condition.=" where a.`groupid`='{$group}'";    
    }else{
      $condition.=" or a.`groupid`='{$group}'";
    }
}
$sql = "select a.`uid`,b.`name`,b.`uname`,c.`unit_sn`,d.`name` as group_name,e.`title` from ".$xoopsDB->prefix("groups_users_link")." as a left join ".$xoopsDB->prefix("users")." as b on a.`uid`=b.`uid` left join ".$xoopsDB->prefix("ugm_apply_users")." as c on a.`uid`=c.`uid`  left join ".$xoopsDB->prefix("groups")." as d on a.`groupid`=d.`groupid`  left join ".$xoopsDB->prefix("ugm_apply_unit")." as e on c.`unit_sn`=e.`sn`  {$condition} group by a.`uid` order by a.`uid`";

SQL可以透過關鍵字「distinct」將查詢的資料不重覆顯示

SQL可以透過關鍵字「distinct」將查詢的資料不重覆顯示
select distinct 欄位名 from 表名 where 查詢準則
備註:distinct 必須與 where 子句聯合使用,否則輸出的資料不會有變化
範例:
SELECT DISTINCT a.uid,b.name,b.uname
FROM  `x4df_groups_users_link` as a left join `x4df_users` as b on a.uid=b.uid
WHERE a.groupid =2
OR a.groupid =3

2013年3月10日 星期日

test

//識別名稱(給程式用的)
$modversion['config'][1]['name'] = 'show_num';
//顯示標題
$modversion['config'][1]['title'] = '_MI_NOTE_SHOW_NUM';
//偏好設定的說明
$modversion['config'][1]['description'] = '_MI_NOTE_SHOW_NUM_DSC';
//偏好設定的輸入欄位類型
$modversion['config'][1]['formtype'] = 'select';
//偏好設定的輸入值型態
$modversion['config'][1]['valuetype'] = 'int';
//偏好設定的選項設定
$modversion['config'][1]['options'] = array(5=>5,10=>10,15=>15);
//偏好設定的預設值。
$modversion['config'][1]['default'] = 10;

2013年1月14日 星期一

釋出xoops模組「petanque」滾球賽務管理(瑞士制)


釋出xoops模組「petanque」滾球賽務管理(瑞士制)
1.無責聲明:本模組為免費釋出之XOOPS模組,育將電腦工作室不負任何使用責任,若您不同意,請勿下載使用!建議先模擬測試沒問題後,再於正式比賽使用!

2.本模組目前為測試版1.1
   增加「對戰表列印」「場次表列印」


3.下載模組
  1. 2012-01-26-10-petanque
  2. 2012-01-27-10-petanque 修正安裝問題
  3. 2013-01-14_滾球賽務軟體_1.1_petanque.zip增加「對戰表列印」「場次表列印」

使用說明


  



2012年12月21日 星期五

取得目前的網址

範例:http://demo.webugm.com/www/test.php?op=test&dom=1
-
-

取得路徑+檔名: $_SERVER['PHP_SELF']=> /www/test.php
取得參數: $_SERVER['QUERY_STRING']=> op=test&dom=1
取得url: $_SERVER['HTTP_HOST']=> demo.webugm.com
取得路徑+檔名+參數: $_SERVER['REQUEST_URI']=> /www/test.php?op=test&dom=1
1.取得目前檔名: basename ($_SERVER['PHP_SELF'])=> test.php
2. 取得目前路徑: str_replace(basename ($_SERVER['PHP_SELF']),"",$_SERVER['PHP_SELF'])=> /www/
3. 取得目前絕對路徑: "http://".$_SERVER["HTTP_HOST"].str_replace(basename ($_SERVER['PHP_SELF']),"",$_SERVER['PHP_SELF']); => http://demo.webugm.com/www/

-
-

2012年12月11日 星期二

XOOPS升級方法


XOOPS升級方法


  1. 關閉網站
  2. 先停用「防護模組」
  3. 備份實體檔案及資料庫
  4. 使用bigdump回復另一個資料庫(備)

2012年12月7日 星期五

phpexcel 寫入到excel文檔


文章來源:http://blog.163.com/wangkangming2008@126/blog/static/7827792820105121581553/


error_reporting(E_ALL);
set_include_path(get_include_path() . PATH_SEPARATOR . 'classes/');//設置路徑

include 'classes/PHPExcel.php';
include 'classes/PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();

$objPHPExcel->getActiveSheet()->getDefaultColumnDimension()->setWidth(16);//設置單元格寬度
$objPHPExcel->getActiveSheet()->setTitle('test');//設置當前工作表的名稱

//註:單元格第一豎是以0開始的,第一行是以1開始的。
for($j=0;$j<10 div="div" j="j">
    $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($j, 1)->getFont()->setBold(true);//設置第一行內容加粗
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($j, 1, 'Test'.($j+1));//設置第一行的標題
    for($i=2;$i<12 div="div" i="i">
        //因為第一行顯示了標題,所以$i是以2開始
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($j, $i, '第'.$i.'行,第'.($j+1).'列');
     }
}


$objPHPExcel->createSheet();//創建一個新的工作表
$objPHPExcel->setActiveSheetIndex(1);//設置為當前工作表

$objPHPExcel->getActiveSheet()->getDefaultColumnDimension()->setWidth(16);//設置單元格寬度
$objPHPExcel->getActiveSheet()->setTitle('Details');//設置當前工作表的名稱



/*
$rowVal = array(0=>'Date', 1=>'IP', 2=>'Email');
foreach($rowVal as $k=>$r){
     $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($k, 1)->getFont()->setBold(true);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($k, 1, $r);
}
*/


//設置第一行標題
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(0, 1)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, 'Date');
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(1, 1)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, 'IP');
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(2, 1)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 1, 'Email');

/***********************
一般這些數據都是從數據庫查詢出來,然後循環輸出。
如:$rs是一個從數據庫查詢出來的數組
$count = count($rs);
for($i=2;$i<$count+2;$i++){
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $i, $rs['date']);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $i, $rs['ip']);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $i, $rs['email']);
}
***********************/


$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 2, '2009-12-1 星期二');
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 2, '127.0.0.1');
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 2, 'andy@palmary.com.hk');


$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 3, '2009-12-1 星期二');
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 3, '127.0.0.1');
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 3, '403126795@qq.com');


$objPHPExcel->setActiveSheetIndex(0);//設置打開excel時顯示哪個工作表
$excelName = 'Excel_'.date("YmdHis").'.xls';//設置導出excel的文件名

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".urlencode($excelName));
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d MYH:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');
?>