Datatable jquery

Datatables jquery 最近剛好在利用,因為server-side用php,改寫成asp 底下是參考的code '*** 底下為server-side SQL處理 ***** 'sql變數儲存的為原本sql語法 sql = "select xxx from xxx" if not isnull( Request.QueryString("iSortCol_0")) then sOrder = "ORDER BY " for i=0 to Request.QueryString("iSortingCols" ) - 1 sOrder = sOrder & fnColumnToField(Request.QueryString("iSortCol_" & i) ) & " " & Request.QueryString("iSortDir_" & i)) & ", " next sOrder = left( sOrder, len(sOrder) - 2 ) end if '/* Filtering - NOTE this does not match the built-in DataTables filtering which does it ' * word by word on any field. It's possible to do here, but concerned about efficiency ' * on very large tables, and MySQL's regex functionality is very limited '*/ sWhere = "" if Request.QueryString("sSearch") <> "" then sWhere = "WHERE search_column_name LIKE '%" & replace(trim(Request.QueryString("sSearch")), "'", "''") & "%' OR " &_ "search_column_name LIKE '%" & replace(trim(Request.QueryString("sSearch")), "'", "''") & "%' " end if sQuery = "SELECT column_name " &_ " FROM (" & sql & ") a " &_ sWhere &_ sOrder '*** 這段是分頁處理 ***** 開始 pagesize = Request.QueryString("iDisplayLength") '每頁大小 page = fix(Request.QueryString("iDisplayStart") / pagesize) + 1 '這段比較有問題,可能有錯 set cmd = server.CreateObject("ADODB.Command") cmd.ActiveConnection = Conn cmd.CommandType = 4 'adCmdText 1; adCmdTable 2; adCmdStoreProc 3; adCmdUnknown 4; adStroeProducure cmd.CommandText = "sp_xxx_store_procedure" 'cmd.Parameters 欄位, 類型, 回傳|輸入|輸出, 長度, 值 'adChar adInteger '1:adParamInput 2:adParamOutput輸出參數 3:adParamReturnValue返回值 cmd.Parameters.Append cmd.CreateParameter("@SqlCommand", 8, 1, 4000, sQuery) cmd.Parameters.Append cmd.CreateParameter("@CurrentPageIndex", 4, 1, 4, page) cmd.Parameters.Append cmd.CreateParameter("@PageSize", 4, 1, 4, pagesize) cmd.Parameters.Append cmd.CreateParameter("@PageCount", 4, 2, 4, pageCount) cmd.Parameters.Append cmd.CreateParameter("@recordCount", 4, 2, 4, recordCount) set rs = cmd.Execute rs.close pageCount = cmd.Parameters("@PageCount").value recordCount = cmd.Parameters("@recordCount").value if pageCount = 0 then pageCount = 1 if page > pageCount then response.Redirect("?page="&pageCount) end if rs.open set rs = rs.NextRecordSet if not rs.eof then '有值才取出來 arr_mn = rs.GetRows '(欄位,第幾列) StringFormat, NumRows, ColumnDelimiter, RowDelimiter, NullExpr end if rs.close set rs=nothing '*** 這段是分頁處理 ***** 結束 '/* Paging */ '使用上面的分頁 iFilteredTotal = recordCount '這個也可能有問題 iTotal = recordCount sOutput = "{" sOutput = sOutput & """sEcho"": " & Request.QueryString("sEcho") & ", " sOutput = sOutput & """iTotalRecords"": " & iTotal & ", " sOutput = sOutput & """iTotalDisplayRecords"": " & iFilteredTotal & ", " sOutput = sOutput & """aaData"": [" sOutput = sOutput & datatable_sdata(arr_mn) & "]}" response.write sOutput function fnColumnToField( i ) '這是放datatables的column,要order欄位 if i = 0 then fnColumnToField = "sort_column_name_1" elseif i = 1 then fnColumnToField = "csort_column_name_2" end if end function 'sp_xxx_store_procedure 為底下程式碼 CREATE PROCEDURE [dbo].[sp_xxx_store_procedure] @SqlCommand NVARCHAR(4000), @CurrentPageIndex INT, @PageSize INT, @PageCount int=0 out, @recordCount int=0 out AS SET nocount ON DECLARE @curl INT, @rowcount INT EXEC sp_cursoropen @curl output, @SqlCommand, @scrollopt=1, @ccopt=1, @rowcount=@rowcount output set @recordCount = @rowcount set @PageCount = ceiling(1.0*@rowcount/@PageSize) --SELECT ceiling(1.0 * @rowcount/@PageSize) as 總頁數, @rowcount as 總筆數, @CurrentPageIndex as 目前頁 --SELECT ceiling(1.0 * @rowcount/@PageSize) as totalpages, @rowcount as totalrecords, @CurrentPageIndex as nowpage SET @CurrentPageIndex = (@CurrentPageIndex - 1) * @PageSize + 1 EXEC sp_cursorfetch @curl, 16, @CurrentPageIndex, @PageSize EXEC sp_cursorclose @curl SET nocount OFF GO 'asp內的function function datatable_sdata(arr) '串dataTable用的data if isarray(arr) then rows_mn = ubound(arr, 2) '取得recordset 的記錄行數' 2代表第2維陣例-幾例 for i=0 to rows_mn arr(0,i) = replace(arr(0,i), chr(13)&chr(10), "") '去掉換行 coumn_1 arr(1,i) = replace(arr(1,i), chr(13)&chr(10), "") '去掉換行 coumn_2 str = str & "[""" & arr(0,i) & """, """ & arr(1,i) & """]," & chr(13) & chr(10) '有沒有chr(13)或chr(10)都行 next datatable_sdata = left(str, len(str)-3) 'chr(13)+chr(10)+, end if end function

2009-09-06 · 3 min · 533 words · Me

測試網頁工具

附上三套測試網頁工具,從外國連線測試,最準啦! 以 http://www.mjj.hk/ 為例 http://tools.pingdom.com 測試結果10 seconds載完,104檔圖……太多了吧! http://webwait.com 讀10次網站 平均1.5秒 http://loadimpact.com 這個最暴力,最浪費時間,以10 clients 11.7s

2009-09-06 · 1 min · 14 words · Me

又搬回來啦!

因為在000webhost上的drupal被關了!(非常生氣!suck!) 現在搬回blogger了! 改天再說明被000webhost情況!

2009-09-06 · 1 min · 3 words · Me

又換地方了

因為blogger會有時候不能post資料,又有幾post失敗…. 所以還是用家裡主機 http://sueboy.page.idv.tw/ofstar/index.php 再次聲明,所有資料皆是用來備份查詢用,只附轉址網址

2005-11-20 · 1 min · 4 words · Me

Ofstar只要php,不用mysql,論壇程式

Ofstar 2.6.0 正式版(php)高速論壇程式下載[11.5] ################# OFSTAR安裝說明 ################# (一) 運行環境需求: PHP (二) 安裝步驟: ( 如果您在安裝過程中出現問題或有疑問,請進入 http://www.ofstar.net/thread.php?fid=1 提問) (1) Linux 或 Freebsd 伺服器下安裝方法 第一步: 將解壓後的檔上傳至你的空間,保持目錄結構不變,假設目錄為ofstar 第二步: 先確認以下目錄或檔屬性為 (777) 可寫模式 /ofstar — 777 目錄 ofstar/bbsdata — 777 目錄 注意此目錄下的所有檔都要設置為 777 ofstar/images — 777 目錄 ofstar/ipdata 默認 目錄 ofstar/require 默認 目錄 ofstar/template/ofstar/css.htm — 777 檔 注意以後您自己加的風格css檔都要設置為 777 ofstar/attachments — 777 目錄 ofstar/session — 777 目錄 ofstar/userdata — 777 目錄 注意此目錄下的所有 目錄 和 檔 都要設置為 777 ofstar/ofstar_data — 777 目錄 注意此目錄下的所有 目錄 和 檔 都要設置為 777 ...

2005-10-30 · 1 min · 120 words · Me