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     

2013年10月30日 星期三

編輯器_插入圖片

1.在新增文章/編輯文章,選擇「影像」工具鈕


2.如圖 



3.如圖  


4.可拖曳上傳數個圖檔,請先將檔名更換為英文檔名  


5.挑選圖片


6.如圖 



7.編輯圖片:對圖片按右鍵



8.可調整寬度、高度、邊框,靠右 ....



2013年10月19日 星期六

更新資料結構 (模組更新)

市場攤販管理,更改資料表結構
function xoops_module_update_ugm_market(&$module, $old_version) {
    GLOBAL $xoopsDB;
    if(!chk_ugm1()) go_ugm1();   # ---- 更改結構為 `e_last` -> DECIMAL( 10, 2 )
    if(!chk_ugm2()) go_ugm2();   # ---- 更改結構為 `e_now` -> DECIMAL( 10, 2 )
    return true;
}

# -------------------- ugm --------------------------------------------------*/

# ---- 更改結構 ugm_market_utility_main  `e_last`  120->130----
function chk_ugm1(){
 global $xoopsDB;
  $sql="select `e_last` from ".$xoopsDB->prefix("ugm_market_utility_main")."";
  $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
  if(mysql_field_type($result,0)=='int')return false ;
  return true;
}
function go_ugm1(){
 global $xoopsDB;
 $sql="ALTER TABLE ".$xoopsDB->prefix("ugm_market_utility_main")." CHANGE `e_last` `e_last` DECIMAL( 10, 2 ) UNSIGNED NOT NULL COMMENT '上期用電度數'";
 $xoopsDB->queryF($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
 return true;
}
# -----------------------------------------
# ---- 更改結構 ugm_market_utility_main  `e_now`  120->130-----
function chk_ugm2(){
 global $xoopsDB;
  $sql="select `e_now` from ".$xoopsDB->prefix("ugm_market_utility_main")."";
  $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
  if(mysql_field_type($result,0)=='int')return false ;
  return true;
}
function go_ugm2(){
 global $xoopsDB;
 $sql="ALTER TABLE ".$xoopsDB->prefix("ugm_market_utility_main")." CHANGE `e_now` `e_now` DECIMAL( 10, 2 ) UNSIGNED NOT NULL COMMENT '本期用電度數'";
 $xoopsDB->queryF($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
 return true;
}
# -----------------------------------------

2013年9月25日 星期三

燈箱

# ---- 在 加上
rel='lyteframe[booth]' title='{$number}' rev='width: 600px; height: 600px; scrolling: yes;'

# ---- 在 head 加上
 //--------------------- 引入jquery -------------------------------------
  if(!file_exists(XOOPS_ROOT_PATH."/modules/tadtools/jquery.php")){
    redirect_header("index.php",3, _TAD_NEED_TADTOOLS);
  }
  include_once XOOPS_ROOT_PATH."/modules/tadtools/jquery.php";
  $jquery_path = get_jquery(); //一般只要此行即可
  # --------  燈箱----------------------------------------
  $lytebox="
  
  ";
# --------------------------------------------------------


# ---- 在switch 加上  --------------------------------------------


  //瀏覽單筆資料->燈箱 圖片
  case "ugm_market_booth_view":
    echo show_lytebox_html(show_one_ugm_market_booth($sn),""); #秀單筆的程式碼
    exit;
    
# ---------------------------------------------------------------

# ---- 在block_function ----------------------------------------

################################################################################
#   燈箱打包碼(內容,標題)
#
#
#
################################################################################
if(!function_exists("show_lytebox_html")){
function show_lytebox_html($content,$title){
  global $xoopsModule;
  # ---- 取得模組目錄名稱 ---------------
  $MDIR=$xoopsModule->getVar('dirname');
  # -------------------------------------
  $main="
       
       
         

         
         {$title}
         
         
         

{$title}

{$content} "; return $main; } }

取得XOOPS內建表單語法

取得XOOPS內建表單語法
群組多選選單
# ---- 引入XOOPS 內建表單物件 ------------------------------- 
include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");
# ---- 預設值 -----------------------------------------------
$group=$xoopsModuleConfig['query_admin'];
# ---- XoopsFormSelectGroup('標題', 'name', 含訪客, '預設值', 高度 ,多選)
$form=new XoopsFormSelectGroup ("", "group", false, $group, 3, true);
# ---- 輸出HTML碼 ------------------------------------------ 
$main_form = $form->render();

# ----- 輸出驗證碼-----------------------------------------------------
$configs="";
$Captcha=new XoopsFormCaptcha ("請輸入驗證碼", 'xoopscaptcha', false, $configs);
# ---- 輸出HTML碼 ------------------------------------------
$form_Captcha = $Captcha->render();

 

2013年8月31日 星期六

bootstrap accordion-menu

bootstrap accordion-menu  架構


參考網站:http://kkbruce.tw/Bootstrap/JavaScript#collapse
<div class="accordion" id="menu_block_1">
 <div class="accordion-group">
  <div class="accordion-heading">
    <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#menu_block_1" href="#menu_sn_1">伸縮選單1</a>
  </div>
  <div id="menu_sn_1" class="accordion-body in collapse">
   <div class="accordion-inner">
            <ul>
                <li>第一層21</li>
                <li>第一層22</li>
                <li>第一層2</li>
            </ul>
   </div>
  </div>
 </div>
 <div class="accordion-group">
  <div class="accordion-heading">
    <a class="accordion-toggle" data-toggle="collapse" data-parent="#menu_block_1" href="#menu_sn_2">伸縮選單2</a>
  </div>
  <div id="menu_sn_2" class="accordion-body in collapse">
   <div class="accordion-inner">
            <ul>
                <li>第一層21</li>
                <li>第一層22</li>
                <li>第一層2</li>
            </ul>
   </div>
  </div>
 </div>
</div>

2013年8月15日 星期四

AJAX JQUERY

範例網址:http://www.tad0616.net/modules/tad_book3/page.php?tbdsn=746

ajax_utility.php
<?php
include_once "header.php";
$market_sn=$_REQUEST['market_sn'];
echo get_market_fill($market_sn);
?>
這裡直返回「填發人員」
js
  <script>
    //開啟表單時
    $(document).ready(function(){
   //由市場決定填發人員
   $.post('ajax_utility.php' , {market_sn:$('#market_sn').val()}, 
        function(data){
          $('#fill').val(data); 
      });
      //市場改變,填發人員改變
      $('#market_sn').change(function(){
        $.post('ajax_utility.php' , {market_sn: $('#market_sn').val()}, 
            function(data){
              $('#fill').val(data); //排序             
         });    
      });
      //自動抓取年度
      $('#limit_year').val($('#year').val()); //年度 
      $('#year').change(function(){
        $('#limit_year').val($('#year').val()); //年度       
      });
      //自動抓取月份
      $('#limit_month').val($('#month').val()); //月份 
      $('#month').change(function(){
        $('#limit_month').val($('#month').val()); //月份       
      });
    });
  </script>
取得值:
$('#market_sn').val()
寫入值:
$('#fill').val(data);

 jQuery的.val ()方法

  1. $('#menu1').val()可以取得id="menu1"的網頁元件的值。
  2. $('#menu1').val('xxx')可以設定id="menu1"的網頁元件的值。

html

<select name='market_sn' size=1 id='market_sn'>{$market_select_option}</select>

<input type='text' name='fill' size='5' value='' id='fill' >

2013年8月5日 星期一

保留修改報名表單的網址

1.報名完成後,按「修改回覆內容」

2.請將「網址」,反白->複製->保存。若有需要修改時,則把網址貼至「網址列」即可修改


2013年8月3日 星期六

模組開發物件

按鈕
$add_button="<a href='{$_SERVER['PHP_SELF']}?op=ugm_market_hire_form'  class='Button'><span>按鈕</span></a>";
固定表格
<table border='0' cellspacing='3' cellpadding='3' id='ugm_tb' style='word-wrap:break-word; word-break:break-all;table-layout:fixed;'>
 表單
<td><input type='text' name='hier[{$sn}][userfees]'  value='{$userfees}' id='userfees_{$sn}' class='validate[required,custom[integer]]' style='width:60px'></td>

<td><input type='text' name='hier[{$sn}][cleaningfees]'  value='{$cleaningfees}' id='cleaningfees_{$sn}' class='validate[required,custom[integer]]' style='width:60px'></td>

<td><input type='text' name='hier[{$sn}][delayfees]'  value='{$delayfees}' id='delayfees_{$sn}' class='validate[custom[integer]]' style='width:60px'></td>

<td><input type='text' name='hier[{$sn}][ps]'  value='{$ps}' id='ps_{$sn}'  style='width:140px'></td>
接收
foreach ($_REQUEST['hier']  as $sn => $data){
    foreach ($data  as $k => $v){
      //以下會產生這些變數:  $userfees, $cleaningfees,$delayfees,$ps
      $$k=$v;
    }
    echo $sn."<br>";
    echo $userfees."<br>";
    echo $cleaningfees."<br>";
    echo $delayfees."<br>";
    echo $ps."<br>";
    die();
 }

2.

$last_button="上一步";