:::

18-8 function.php

01<?php
02/*
03function.php 是用來放置共同函數的檔案
04若有一些函數是前後台檔案會用到的,那麼可以將該函數放在這裡。
05*/
06 
07 
08//先確認 TadTools 是否存在
09if(!file_exists(XOOPS_ROOT_PATH."/modules/tadtools/tad_function.php")){
10  //若不存在提示安裝
11  redirect_header("http://www.tad0616.net/modules/tad_uploader/index.php?of_cat_sn=50",3, _TAD_NEED_TADTOOLS);
12}
13//引入TadTools的函式庫,若沒載入此行,所有 tadtools 相關功能將無法使用
14include_once XOOPS_ROOT_PATH."/modules/tadtools/tad_function.php";
15 
16 
17 
18//榮譽榜一覽
19function list_honor(){
20  global $xoopsTpl , $xoopsDB;
21 
22  $myts =& MyTextSanitizer::getInstance();
23 
24  //資料表套用前置字串
25  $tbl=$xoopsDB->prefix("tad_honor");
26  //撈取資料表內容的SQL語法
27  $sql="select * from {$tbl} order by `honor_date` desc";
28 
29  //getPageBar($原sql語法, 每頁顯示幾筆資料, 最多顯示幾個頁數選項);
30  $PageBar=getPageBar($sql, 10 , 10 );
31  $bar=$PageBar['bar'];
32  $sql=$PageBar['sql'];
33  $total=$PageBar['total'];
34 
35  //送到資料庫執行
36  $result = $xoopsDB->query($sql) or die(mysql_error());
37  //取回一筆資料
38  $i=1;
39  $all_data="";
40  while($all=$xoopsDB->fetchArray($result)){
41 
42    $all['honor_year']=$myts->htmlSpecialChars($all['honor_year']);
43    $all['honor_date']=$myts->htmlSpecialChars($all['honor_date']);
44    $all['honor_students']=$myts->htmlSpecialChars($all['honor_students']);
45    $all['honor_descript']=$myts->htmlSpecialChars($all['honor_descript']);
46    $all['honor_teachers']=$myts->htmlSpecialChars($all['honor_teachers']);
47    $all['honor_note']=$myts->htmlSpecialChars($all['honor_note']);
48 
49    $all_data[$i]=$all;
50    $i++;
51  }
52 
53  //將資料陣列套到樣板檔
54  $xoopsTpl->assign('all_data' , $all_data);
55  $xoopsTpl->assign('bar' , $bar);
56  $xoopsTpl->assign('temp_title' , '榮譽榜一覽');
57 
58}
59 
60 
61?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.cp27.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D967%26tbsn%3D25

書籍目錄

展開 | 闔起

線上使用者

145人線上 (24人在瀏覽線上書籍)

會員: 0

訪客: 145

更多…