2013年11月15日 星期五

chainedSelects 連動選單

參考網站
參考網站

連動選單

script

//---引入Js

//-----------------------------------------------------------
  
  

OP


  //連動選單
  case "get_ugm_search_class_json":
  $get_ugm_search_class_json[] = get_ugm_search_class_json($_GET['_value']);
  echo json_encode($get_ugm_search_class_json);
  exit;
  # ------------------------------------------------------------------------

  //選項
  function get_ugm_search_class_json($kind_sn="0"){
    global $xoopsDB;
    $sql = "select * from ".$xoopsDB->prefix("ugm_search_class")." where `kind_sn`='{$kind_sn}' order by `sn`";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
    //$opt[]="請選擇";
    while(list($sn,$kind_sn,$title)=$xoopsDB->fetchRow($result)){
      $opt[$sn]=$title;
    }
     return $opt;    
  }

html

 $main=" 

 
    "._MA_UGMSEARCH_KIND_SN."
   
      
    
  

 
 
    "._MA_UGMSEARCH_CLASS_SN."
   
      
    
  "

2013年11月3日 星期日

PHP EXCEL 匯出

設定寬度

# 設定 A 欄 寬度(一次只能一個欄)
$objPHPExcel->getActiveSheet()->getColumnDimensionByColumn(0)->setWidth(20);
$objPHPExcel->getActiveSheet()->getColumnDimension("A")->setWidth(20);

2013年11月1日 星期五

MYSQL 排名

參考來源:http://www.1keydata.com/tw/sql/sql-rank.html



SELECT a1.Name, a1.Sales, COUNT(a2.Sales) Sales_Rank 
FROM Total_Sales a1, Total_Sales a2 
WHERE a1.Sales < a2.Sales OR (a1.Sales=a2.Sales AND a1.Name = a2.Name) 
GROUP BY a1.Name, a1.Sales 
ORDER BY a1.Sales DESC, a1.Name DESC;


  # ------------------------------------------- 
 $sql="
 select a.term_class_student_sn, a.avg1, count(b.avg1) rank 
 from 
   (select sn as term_class_student_sn ,avg1
    from ".$xoopsDB->prefix("ugm_scroeqry_term_class_student")."  
    where term_class_sn='{$term_class_sn}' and enable='1') a, 
   
   (select sn as term_class_student_sn ,avg1
   from ".$xoopsDB->prefix("ugm_scroeqry_term_class_student")."  
   where term_class_sn='{$term_class_sn}' and enable='1') b 
   
   where a.avg1 < b.avg1 or (a.avg1=b.avg1 and a.term_class_student_sn = b.term_class_student_sn) 
   group by a.term_class_student_sn, a.avg1 
   order by a.avg1 desc, a.term_class_student_sn desc;
 ";die($sql);
  # ----http://www.1keydata.com/tw/sql/sql-rank.html