圖示:
2012年2月1日 星期三
2012年1月30日 星期一
JavaScript Date Time Picker
網址
download
更改datetimepicker_css.js(版本Version: 2.2.2)
download
更改datetimepicker_css.js(版本Version: 2.2.2)
var StartYear =2010; //可以指定起始的年度 var imageFilesPath = "xxx"; //指定圖片路徑
標籤:
javascript
2012年1月19日 星期四
定位、間距與內襯
■position:
定位規則有absolute | relative | static(預設值)分別表示絕對位置、相對位置和靜態位置
■top:數值;right:數值;bottom:數值;left:數值;
這是指元素各邊緣與定位點的偏移量,就絕對定位而言定位點是包含元素的區塊;就相對定位而言定位點是元素原本的位置。
參考資料:必學的部落格CSS語法(二)-定位、間距與內襯
定位規則有absolute | relative | static(預設值)分別表示絕對位置、相對位置和靜態位置
■top:數值;right:數值;bottom:數值;left:數值;
這是指元素各邊緣與定位點的偏移量,就絕對定位而言定位點是包含元素的區塊;就相對定位而言定位點是元素原本的位置。
參考資料:必學的部落格CSS語法(二)-定位、間距與內襯
解決html5在ie不支援header 的問題
資料:http://www.maya.com.tw/news805.php?id=105&PHPSESSID=8ee94f879a2d04212a48ec66a02f80f5
直接添加到網頁中。 程序代碼
border 邊框
以下為常見邊框:
border-style 屬性指定邊框的樣式 solid實線、dashed虛線、 double雙線、 點線
border-width 屬性是用來設定邊框的寬度。可用的值為 thin (薄)、medium (中等)、thick (厚),或是一個數字。
border-color 屬性是用來設定邊寬的顏色。
border-top-, border-left-, border-bottom-, border-right-
border 若四邊的邊框屬性都一樣,那我們可以用一個 border 屬性來描述,而不必四個邊都描述一次。另外,我們可以在同一行一次宣告邊框樣式、邊框寬度、以及邊框顏色。
border-style 屬性指定邊框的樣式 solid實線、dashed虛線、 double雙線、 點線
border-width 屬性是用來設定邊框的寬度。可用的值為 thin (薄)、medium (中等)、thick (厚),或是一個數字。
border-color 屬性是用來設定邊寬的顏色。
border-top-, border-left-, border-bottom-, border-right-
border 若四邊的邊框屬性都一樣,那我們可以用一個 border 屬性來描述,而不必四個邊都描述一次。另外,我們可以在同一行一次宣告邊框樣式、邊框寬度、以及邊框顏色。
CSS width height 屬性
width: 这個属性定義元素内容區的宽度,在内容区外面可以增加内邊距、邊框和外邊距。
height: 這個属性定義元素内容區的高度,在内容区外面可以增加内边距、边框和外边距。
默認值:auto
FONT
height: 這個属性定義元素内容區的高度,在内容区外面可以增加内边距、边框和外边距。
默認值:auto
JavaScript 語法:object.style.width="50px"
行內語法:style="width:20px"
p
{
height:100px;
width:100px;
}
段落屬性的設定段落屬性的設定
利用這些設定可以輕易的控制字距、行高、縮排、凸排、水平對齊、垂直對齊等。這些性質對網頁設計的排版非常有用!
功能 : 設定文字行列高度 ( 可設單位屬性 : 點pt、英寸in、公分cm、像素px、百分比% )
語法 : { LINE-HEIGHT : NORMAL︱( number )︱( length )︱( percentage ) }
範例 : {LINE-HEIGHT:10pt}
此性質可設定列高,可指定特徵字normal設為預設值,或指定含單位的長度值,或百分比(參照於父元件)均可。如line-height:3px,則設定列高為3px。
FONT
p.ex1
{
font:15px arial,sans-serif;
}
p.ex2
{
font:italic bold 12px/30px Georgia, serif;
}
2012年1月18日 星期三
PHP 補零
資料來源:http://blog.hsin.tw/2009/php-pad-a-string/
資料來源:http://boray06.blogspot.com/2011/06/php_27.html
資料來源:http://boray06.blogspot.com/2011/06/php_27.html
string str_pad ( string $input , int $pad_length [, string $pad_string= " " [, int $pad_type= STR_PAD_RIGHT ]] ) $input : 原字串 $pad_length : 補齊後的位數 $pad_string : 用來補齊的字串 $pad_type : 補齊的方式 有三種,STR_PAD_RIGHT (由右邊補)、STR_PAD_LEFT (由左邊補)、STR_PAD_BOTH (左右兩邊都補), 預設為STR_PAD_RIGHT $value = 7; //將數字由左邊補零至三位數 $value = str_pad($value,3,'0',STR_PAD_LEFT); echo $value; // 結果會印出 007;
CSS hack 慎用
為了解決ie6的css 問題,用了css hack。
如果只有少量,倒是無所謂,但又有新的寫法可以選擇了。
如果只有少量,倒是無所謂,但又有新的寫法可以選擇了。
1. 除IE外都可识别
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
慎用mysql的enum
原因:我的enum('0','1');
發現怎麼抓都是0
後來,就設為char~"~ 參考網址:http://www.neatstudio.com/show-1498-1.shtml
發現怎麼抓都是0
後來,就設為char~"~ 參考網址:http://www.neatstudio.com/show-1498-1.shtml
2012年1月17日 星期二
jQuery Scroll to Top Control v1.1
網址:http://www.dynamicdrive.com/dynamicindex3/scrolltop.htm
引用檔:scrolltopcontrol.js
圖片:up.jpg
修改scrolltopcontrol.js的圖片路徑。
引用檔:scrolltopcontrol.js
圖片:up.jpg
修改scrolltopcontrol.js的圖片路徑。
setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
controlHTML: '
', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
controlattrs: {offsetx:15, offsety:15}, //offset of control relative to right/ bottom of window corner
anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links
preg_match 正規表示式比對
int preg_match ( string pattern, string subject [, array matches [, int flags]])
本函式以 pattern 的規則來剖析比對字串 subject。比對結果傳回的值放在陣列參數 matches 之中,matches[0]
內容就是原字串 subject、matches[1] 為第一個合乎規則的字串、matches[2] 就是第二個合乎規則的字串,餘類推。
若省略參數 matches,則只是單純地比對,找到則傳回值為 true。
本函式以 pattern 的規則來剖析比對字串 subject。比對結果傳回的值放在陣列參數 matches 之中,matches[0]
內容就是原字串 subject、matches[1] 為第一個合乎規則的字串、matches[2] 就是第二個合乎規則的字串,餘類推。
若省略參數 matches,則只是單純地比對,找到則傳回值為 true。
// the "i" after the pattern delimiter indicates a case-insensitive search
if (preg_match ("/php/i", "PHP is the web scripting language of choice.")) {
print "A match was found.";
} else {
print "A match was not found.";
}
認證IP是否正確
function validIP($ip){
return preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $ip);
}
網站實例:
preg_match("/product[0-9]{4}.html/i",$_SERVER['REQUEST_URI']
參考regular expressions
2012年1月16日 星期一
Jquery 的show 及hide
ID:check 為checkBox ID: cCArea 為顯示的AREA
利用check Box來顯示或隱藏。
2013.04.08加入 有多個check需要使用顯示與隱藏。加入副程式 same_check以減少程式碼。
利用check Box來顯示或隱藏。
2013.04.08加入 有多個check需要使用顯示與隱藏。加入副程式 same_check以減少程式碼。
//副程式
function same_check(m_objc,objc){
if(m_objc){
$(objc).show("fast");
}else{
$(objc).hide("fast");
}
}
//jquery 主要的
$("#check").click(function(){
same_check($(this).is(":checked"),"#cCArea");
})
從多個checkbox中判斷哪一個被選取,和要顯示的區域
案例:只有兩個checkbox ,從中2選一。
if($("#cch2").attr("checked")){
$("#cck1Area").show("fast");
$("#cck2Area").hide("fast");
}
2012年1月12日 星期四
檔案操作
列出資料夾裡面的組成:scandir
可以使用含有「萬用字元」的字串當做參數,取得檔案列表
bool copy ( string $source , string $dest [, resource $context ] )
unlink()函式能刪除名稱為 filename 的檔案,成功便傳回 true ,失敗則傳回 false
filesize(filename):得知檔案的大小。
副檔名取得:
新檔名:
$number = strpos($file_name,".");
$sub_file_name = substr($file_name,$number+1);
$sub_number = strpos($file_name_samll,".");
$sub_file_name_small= substr($file_name_samll,$number+1);
$new_file_name = time()."_".$number.".".$sub_file_name;
$dir = '/tmp'; array scandir(string directory[,int sorting_order] 注:sorting_order 預設為1 $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2);列出資料夾裡面的組成:glob
可以使用含有「萬用字元」的字串當做參數,取得檔案列表
格式:glob($pattern);
glob('*.txt'); //只會取得txt附檔名的檔案
檔案之複製、刪除、更名bool copy ( string $source , string $dest [, resource $context ] )
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
copy 的權限錯誤,只要把資料夾的write打開即可解決。 錯誤範例: Warning: copy( ) [function.copy]: failed to open stream: Permission denied int unlink ( string filename );unlink()函式能刪除名稱為 filename 的檔案,成功便傳回 true ,失敗則傳回 false
filesize(filename):得知檔案的大小。
副檔名取得:
$number = strpos($filename,"."); $file_body = substr($filename,0,$number);
新檔名:
$number = strpos($file_name,".");
$sub_file_name = substr($file_name,$number+1);
$sub_number = strpos($file_name_samll,".");
$sub_file_name_small= substr($file_name_samll,$number+1);
$new_file_name = time()."_".$number.".".$sub_file_name;
2012年1月10日 星期二
回上一頁 GO BACK
相關詞:返回連結
到某個網址:
EX:
Q:我使用回到上一頁的javascript:window.history. back() 會出現 上一頁 網頁已過期的訊息~"~
ans:只要使用過form post 的環境下,回到上一頁會有出現已過期的訊息。
只要用"到某個網址"的方過就可以解決這個問題。
<input type='button' onclick='javascript:window.history.back()' value='哈哈' />
到某個網址:
EX:
self.location='目標網址';
Q:我使用回到上一頁的javascript:window.history. back() 會出現 上一頁 網頁已過期的訊息~"~
ans:只要使用過form post 的環境下,回到上一頁會有出現已過期的訊息。
只要用"到某個網址"的方過就可以解決這個問題。
標籤:
javascript
check radio box 美化
DEMO:http://www.hieu.co.uk/Examples/CustomizeHTMLControls/CustomizeHTMLControls.htm
網址:http://www.hieu.co.uk/blog/index.php/2009/07/09/customize-html-control-with-jquery-checkbox-radio/
網址:http://www.hieu.co.uk/blog/index.php/2009/07/09/customize-html-control-with-jquery-checkbox-radio/
標籤:
javascript
2012年1月6日 星期五
2012年1月5日 星期四
UI Datepicker
demo:http://jqueryui.com/demos/datepicker/
2012/09/26 下午 新增
datetimepick2
<script type="text/css">
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
</script>
2012/09/26 新增<script src='../script/jquery-1.8.0.min.js'></script>
<link rel="stylesheet" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery-ui.css" type="text/css" media="all">
<script src="../script/jquery.ui.core.js"></script>
<script src="../script/jquery.ui.widget.js"></script>
<script src="../script/jquery.ui.datepicker.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
2012/09/26 下午 新增
datetimepick2
<script language="javascript" type="text/javascript" charset="utf-8" src="../script/datetimepicker2/datetimepicker_css.js"></script>
<img src="../script/datetimepicker2/images/cal.gif" style="width:16px;height:16px;cursor:pointer;" border="0" alt="Pick a date" onclick="javascript:NewCssCal('order_pay_date','yyyymmdd','arrow',true,'24')"><small>按圖示即可輸入時間</small><input type="text" id="order_pay_date" name="order_pay_date" disabled="disabled">
不對稱
function btn_editTime(auto){
var a=(new Date).getTime();
var own_path="../XXX.php?action=cc&a="+a;
$.get(own_path,{c_auto:auto}, function (data){
var XXX =data.00XX;
var YYY =data.00YY;
var $dialog = $("#showOneDetail").dialog({
title: 'Detail',
autoOpen: false,
bgiframe: true,
width: 450,
height: 420,
modal: true,
draggable: true,
resizable: false,
overlay:{opacity: 0.7, background: "#FF8899" },
buttons: {
'close': function() {
$(this).dialog('close');
}
}
});
//日期時間
$("#example16_start").val(XXX);
$("#example16_start_time").val(YYY);
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
},"json")
}
................ ........... ...........
標籤:
javascript,
PHP
彈跳視窗、關閉視窗
引入檔案:
場景:表格下每列的button
關鍵字:小視窗、跳出。
關鍵字:小視窗關閉後刷主視窗頁面
子視窗:

EX:點擊連結會使用window.open 另開無邊的視窗;在連結上右鍵又可以開啟分頁。
關閉視窗
場景:表格下每列的button
$editBox=
關鍵字:小視窗、跳出。
var newwin = null;
function opwin(news_id){
newwin=window.open('thron/issue-news.php?id='+news_id,'nw','width=680px,height=580px,resizable=yes,scrollbars=yes,status=0');
newwin.moveTo(200,10);
}
test
關鍵字:小視窗關閉後刷主視窗頁面
子視窗:
<SCRIPT LANGUAGE="JavaScript">
function closeMeAndReloadParent()
{
opener.location.reload();
window.close();
}
<SCRIPT">
<body onunload='closeMeAndReloadParent()'>

EX:點擊連結會使用window.open 另開無邊的視窗;在連結上右鍵又可以開啟分頁。
<a href='xxx.php?id={$data[$i]['msnauto']}' onClick="opwin({$data[$i]['msnauto']});return false;" >
function opwin(news_id){
newwin=window.open('xxx.php?id='+news_id,'nw','width=680px,height=680px,resizable=yes,scrollbars=yes,status=0');
newwin.moveTo(200,10);
}
關閉視窗
javascript:
function doClose(){this.close();}
標籤:
javascript,
PHP
tablesorter
網址:http://tablesorter.com/docs/example-pager.html
打開就有排序的反白:
程式碼 jQuery:
$(document).ready(function() {
$("table")
.tablesorter({widthFixed: true, widgets: ['zebra']})
.tablesorterPager({container: $("#pager")});
});
20120928新增打開就有排序的反白:
$("#myTable").tablesorter({sortList: [[0,1]]} )
.tablesorterPager({container: $("#pager")});
$(document).ready(function() {
$("table").tablesorter({
// pass the headers argument and assing a object
headers: {
// assign the secound column (we start counting zero)
1: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
2: {
// disable it by setting the property sorter to false
sorter: false
}
}
});
});
針對table每頁幾行,進行優化 在紅色的兩個方塊本來是選上面20下面還是依然是10,優化的話,可以讓上面兩個同步。程式碼 jQuery:
BODY:
你的table資料
標籤:
javascript
2012年1月4日 星期三
facebook connect
新增facebook的apps https://developers.facebook.com/apps
參考:
參考:
- Authentication
- Facebook API PHP SDK裡面的資料因版本的更新,我在這邊做備註:引用的檔案為三個:example.php、facebook.php、base_facebook.php。exmplate.php裡面有些函數不能用,就用裡面函數有不支援就用範例即可。
facebook XXX人說這讚。成為你朋友中第一個說這讚的人。
2012年1月2日 星期一
HTML 5 對於 table的支援度
css 版面置中
html, body {height: 100%; text-align: center;}
#container {
position: relative;
width:960px; height:100%;
margin:0 auto;/*ff 置中*/ *margin:0;/*ie 置中*/
text-align:left;
}
body > #container {height: auto; min-height: 100%;}
----------------------------------------------------------------------------
#container是最外層的div
CSS 分享 (2) CSS 基本概念與語法
View more presentations from 知世‧安索帕 台北 (使用經驗設計中心)
2012年1月1日 星期日
北80國小 mm_menu.js
問題:網站上的menu引用 mm_menu.js 發現在IE 8 上有錯誤
解法:把以下的語法註解掉即行。
解法:把以下的語法註解掉即行。
var lite = FIND("menuLite" + x);
var s = lite.style;
s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
s.height = s.pixelHeight + 'px';
s.pixelWidth = menu.menuWidth + (menu.menuBorder * 2);
s.width = s.pixelWidth + 'px';
if( menu.menuBgOpaque ) s.backgroundColor = menu.menuLiteBgColor;
var body = FIND("menuFg" + x);
s = body.style;
s.pixelHeight = menu.menuHeight + menu.menuBorder;
s.height = s.pixelHeight + 'px';
s.pixelWidth = menu.menuWidth + menu.menuBorder;
s.width = s.pixelWidth + 'px';
if( menu.menuBgOpaque ) s.backgroundColor = menu.bgColor;
s = menuLayer.style;
s.pixelWidth = menu.menuWidth + (menu.menuBorder * 4);
s.width = s.pixelWidth + 'px';
s.pixelHeight = menu.menuHeight+(menu.menuBorder*4);
s.height = s.pixelHeight + 'px';
標籤:
工作,
javascript
HTML5 起始1
進入HTML 5的年代,對於前端開發人員,著實是一大福因,因為HTML 5 致力於解決跨瀏覽器問題,也可以部份取代原來的JavaScript。
借助於HTML5 前端開發人員可以減少開發時間,開發出功能更加強大的人機介面。
HTML5尊守以下三點規則:
<meta charset='utf-8'>
html 5 轉換
快速將-doctype-等標籤-轉換成-html5-格式
一定要看 - 30個超優秀的 HTML5 學習資源 架構圖:
借助於HTML5 前端開發人員可以減少開發時間,開發出功能更加強大的人機介面。
HTML5尊守以下三點規則:
- 相容性:HTML5在老版本的瀏覽器上也可以正常執行
- 實用性:HTML5內部並沒有特別複雜的功能,它只封裝了那些常用的簡單功能。
- 非革命性的發展:它只是一種「妥協式」的標準
<!DOCTYPE HTML> <html> <head> <title>Title of the document</title> </head> <body> The content of the document...... </body> </html>meta 為utf-8 在 HTML5下可以縮減為:
<meta charset='utf-8'>
html 5 轉換
快速將-doctype-等標籤-轉換成-html5-格式
一定要看 - 30個超優秀的 HTML5 學習資源 架構圖:
書單:HTML5:建置與執行
2011年12月30日 星期五
YAHOO! 的API網站認證
環境:智邦的虛擬主機。
問題:把yahoo!APIs需要認證的 檔案放在domain的root,在經過yahoo!的認證網頁認證,但一直過不了,也把yahoo的環境用成US,也依然解決不了。
解決: 把下面的.htaccess放在www的root,就可以認證通過了。
在www底下加入.htaccess
內容:
這樣網站認證就會過了!!
我參考的網頁:
http://programer.pixnet.net/blog/post/53935479
問題:把yahoo!APIs需要認證的 檔案放在domain的root,在經過yahoo!的認證網頁認證,但一直過不了,也把yahoo的環境用成US,也依然解決不了。
解決: 把下面的.htaccess放在www的root,就可以認證通過了。
在www底下加入.htaccess
內容:
SecFilterEngine Off
SecFilterScanPOST Off
這樣網站認證就會過了!!
我參考的網頁:
http://programer.pixnet.net/blog/post/53935479
2011年12月27日 星期二
引用google的jquery
聽說可以減少連結的時間。
網址:http://code.google.com/intl/zh-TW/apis/libraries/devguide.html
http://www.ezdiy.org/forum/viewtopic.php?id=362
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>參考如下:
網址:http://code.google.com/intl/zh-TW/apis/libraries/devguide.html
http://www.ezdiy.org/forum/viewtopic.php?id=362
jquery 丟值到textarea
$("textarea#showMerchandiseContent").html('654');
$("textarea#ExampleMessage").val(result.exampleMessage);
dom中有value属性的是Button ImageButton、 CheckBox、 File、 Hidden、Password、Radio、 Reset 、Submit、 Text、 Option、 textarea
textarea
属性:
Common -- 一般属性
cols -- 多行输入域的列数
rows -- 多行输入域的行数
accesskey -- 表单的快捷键访问方式
disabled -- 输入域无法获得焦点,无法选择,以灰色显示,在表单中不起任何作用
readonly -- 输入域可以选择,但是无法修改
tabindex -- 输入域,使用"tab"键的遍历顺序
2011年12月26日 星期一
CKEDITOR 所見即所得
CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it
圖片上傳 http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29
演示: http://ckeditor.com/demo
CKeditor網頁編輯器與CKfinder上傳整合應用
http://www.minwt.com/?p=2848
要實現ckfinder 線上預覽的功能,似乎要買完整版的才有辦法使用。
在編輯完成後,雖然前端可以看的到,但要編輯時會出現圖片叉燒包,
點它右鍵內容中的網址如下:http://localhost/%22/CKEdit/upload/images/Taiwan.jpg/%22
顯示有%22 真的是一件麻煩的事
參考 http://www.minwt.com/?p=2848裡面的迴響
改使用window.open(),發現ckeditor 的areatext可以抓到值了,只是ckeditor沒辦法show出圖來


圖片上傳 http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29
演示: http://ckeditor.com/demo
CKeditor網頁編輯器與CKfinder上傳整合應用
http://www.minwt.com/?p=2848
要實現ckfinder 線上預覽的功能,似乎要買完整版的才有辦法使用。
在編輯完成後,雖然前端可以看的到,但要編輯時會出現圖片叉燒包,
點它右鍵內容中的網址如下:http://localhost/%22/CKEdit/upload/images/Taiwan.jpg/%22
顯示有%22 真的是一件麻煩的事
參考 http://www.minwt.com/?p=2848裡面的迴響
改使用window.open(),發現ckeditor 的areatext可以抓到值了,只是ckeditor沒辦法show出圖來

可以在線上瀏覽圖片了。

呼叫頁面(php)範例
1.6 版才有的 .prop()
if($("#update_submit").prop("disabled")==false)
$("#update_submit").prop("disabled",true)
1.6以前的.attr可以使用。
但在1.6後使用會有問題。
延伸閱讀:http://blog.xuite.net/vexed/tech/44905647
SUBSTR 截取字串
SUBSTR(str,pos): 由中,選出所有從第位置開始的字元。請注意,這個語法不適用於SQL Server上。
SUBSTR(str,pos,len): 由中的第位置開始,選出接下去的個字元。
參考1
參考2
求平均值Average
語法:AVG([DISTINCT | ALL] n) ->數值
求群組內的n之平均值。
算出資料筆數
語法:count([DISTINCT |ALL] e)->數值
求群組內的資料筆數(列數)
抽出字串左邊部份
LEFT(s,n) ->字串
取出s字串左邊的部份字串 *中文為雙位元組所以有可能會被截斷
去掉開始和結束的空白
$str = trim($str);
SUBSTR(str,pos,len): 由
參考1
參考2
求平均值Average
語法:AVG([DISTINCT | ALL] n) ->數值
求群組內的n之平均值。
算出資料筆數
語法:count([DISTINCT |ALL] e)->數值
求群組內的資料筆數(列數)
抽出字串左邊部份
LEFT(s,n) ->字串
取出s字串左邊的部份字串 *中文為雙位元組所以有可能會被截斷
去掉開始和結束的空白
$str = trim($str);
2011年12月25日 星期日
禁止輸入非數字(副程式)
function KeyPress(objTR){
//只允許錄入數據字符 0-9 和小數點
// var objTR = document.document.password;
var txtval= objTR.value;
var key = event.keyCode;
//alert(key);
if((key < 48||key > 57) && (key < 96 || key >105)&&(key != 46 && key !=8 && key !=17 && key !=9)){
objTR.value = '';
alert('Pleas enter number digits');
}
}
第二個方法:
標籤:
javascript
使用navicat連接MYSQL
2011年12月23日 星期五
爾必達

爾必達(英語:Elpida Memory, Inc.),日本記憶體公司
2011年2月25日,爾必達在台灣證券交易所掛牌發行台灣存託憑證(TDR,臺證所:916665),為該交易所第一個日商公司TDR。
金士頓所使用的 爾必達(Elpida)顆粒
相關新聞:
南科 否認與爾必達合併2011.12.23 03:36 am
2011年12月22日 星期四
SWFUpload 套件
SWFUpload consists of 4 pieces:
Initialization and Settings
JavaScript library
Example: Adding SWFUpload.js to a page
The Event Handlers
Example: SWFUpload event handlers and initialization.
DEMO:
http://demo.swfupload.org/v220/index.htm
- Initialization and Settings (JavaScript)
- JavaScript library: SWFUpload.js
- Flash Control: swfupload.swf
- The Event Handlers (JavaScript)
Initialization and Settings
var swfu;
window.onload = function () {
var settings_object = {
upload_url : "http://www.swfupload.org/upload.php",
flash_url : "http://www.swfupload.org/swfupload.swf",
file_size_limit : "20 MB",
button_placeholder_id : "spanSWFUploadButton"
};
swfu = new SWFUpload(settings_object);
};
JavaScript library
Example: Adding SWFUpload.js to a page
The Event Handlers
Example: SWFUpload event handlers and initialization.
// The uploadStart event handler. This function variable is assigned to upload_start_handler in the settings object
var myCustomUploadStartEventHandler = function (file) {
var continue_with_upload;
if (file.name === "the sky is blue") {
continue_with_upload = true;
} else {
continue_with_upload = false;
}
return continue_with_upload;
};
// The uploadSuccess event handler. This function variable is assigned to upload_success_handler in the settings object
var myCustomUploadSuccessEventHandler = function (file, server_data, receivedResponse) {
alert("The file " + file.name + " has been delivered to the server. The server responded with " + server_data); }; // Create the SWFUpload Object
var swfu = new SWFUpload({
upload_url : "http://www.swfupload.org/upload.php",
flash_url : "http://www.swfupload.org/swfupload.swf",
file_size_limit : "200 MB",
upload_start_handler : myCustomUploadStartEventHandler,
upload_success_handler : myCustomUploadSuccessEventHandler }
);
DEMO:
http://demo.swfupload.org/v220/index.htm
Mysql日期時間和時間函數
所有記錄,其date_col的值是在最30天以內:
DAYOFWEEK(date)
返回日期date的星期索引(1=星期天,2=星期一, ……7=星期六)。這些索引值對應ODBC標準。
DAYOFYEAR(date)
返回date在一年中的日數, 在1到366范圍內。
限制在 24小時內:秒數相減小於24小時(86400秒)
mysql> SELECT * FROM table
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
TO_DAYS(date)
mysql> SELECT TO_DAYS(950501);
-> 728779
mysql> SELECT TO_DAYS('1997-10-07');
-> 729669
DAYOFWEEK(date)
返回日期date的星期索引(1=星期天,2=星期一, ……7=星期六)。這些索引值對應ODBC標準。
mysql> select DAYOFWEEK('1998-02-03');
-> 3
DAYOFYEAR(date)
返回date在一年中的日數, 在1到366范圍內。
mysql> select DAYOFYEAR('1998-02-03');
-> 34
限制在 24小時內:秒數相減小於24小時(86400秒)
((unix_timestamp(NOW())- unix_timestamp(`startTime`)) <'86400')
select unix_timestamp('2008-08-08'); -- 1218124800
限制:一個ip一天只記錄一次點擊物品
$sql="select count(*) as c from web_log where DATE(now())=DATE(time) and commodity_sn='$sn' and ip='$address'";
$serachWebLogData=lazy_get_line($sql);
if(! $serachWebLogData['c']>=1){
//如果沒有資料就可以做插入
$sql="insert....";
客戶端的IP及瀏覽器
if (!empty($_SERVER['HTTP_CLIENT_IP']))
$ip=$_SERVER['HTTP_CLIENT_IP'];
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
else
$ip=$_SERVER['REMOTE_ADDR'];
browser()
function browser(){
$browsers = array("firefox", "msie", "opera", "chrome", "safari",
"mozilla", "seamonkey","konqueror", "netscape",
"gecko", "navigator", "mosaic", "lynx", "amaya",
"omniweb", "avant", "camino", "flock", "aol");
$agent=strtolower($_SERVER["HTTP_USER_AGENT"]);
//echo $browser;
foreach($browsers as $browser){
if (preg_match("#($browser)[/ ]?([0-9.]*)#", $agent, $match)){
$browser_version=$match[1].$match[2];
break ;
}
}
$mobileAgents = array(
"iphone",
"ipad",
"android",
"mini",
"mobi",
"portable",
"playstation",
"palm",
"hiptop",
"avantgo",
"plucker",
"xiino",
"blazer",
"eclair",
"froyo");
$OSName=array('nt 5.1'=>"XP",'nt 5.0'=>'2000','nt 5.1'=>'XP','nt 5.2'=>"Windows Server 2003",'nt 6.0'=>'vista、2008','nt 6.1'=>'Win7,Server 2008 R2','nt 6.2'=>'Windows8');
if(eregi('nt 5.1',$agent)){
$browser_os=$OSName['nt 5.1'];
}else if(eregi('nt 5.0',$agent)){
$browser_os=$OSName['nt 5.0'];
}else if(eregi('nt 5.1',$agent)){
$browser_os=$OSName['nt 5.1'];
}else if(eregi('nt 5.2',$agent)){
$browser_os=$OSName['nt 5.2'];
}else if(eregi('nt 6.0',$browser)){
$browser_os=$OSName['nt 6.0'];
}else if(eregi('nt 6.1',$agent)){
$browser_os=$OSName['nt 6.1'];
}else if(eregi('nt 6.2',$agent)){
$browser_os=$OSName['nt 6.2'];
}else{
foreach($mobileAgents as $check) {
if(stripos($agent, $check)) {
$browser_os=$check;
break;
}
}
}
return $browser_version."[{$browser_os}]";
}
PHPMailer - PHP email class
Software: PHPMailer - PHP email class |
| Version: 2.0.4 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Author: Andy Prevost (project admininistrator) |
| Author: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers)
----------------------------------------------------------------------------|
CASE 2 aXXl
要注意Gmail 的 SMTP主機固定位址是 smtp.gmail.com,必須使用 465 埠以 SSL 的方式來連線
所以apache需要灌ssl才行。
| Version: 2.0.4 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Author: Andy Prevost (project admininistrator) |
| Author: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers)
----------------------------------------------------------------------------|
// 建立 PHPMailer 物件及設定 SMTP 登入資訊
require("../phpMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "remote.smtp.server"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "me@localhost"; // SMTP username
$mail->Password = "123456"; // SMTP password
$mail->From = "myemail@localhost";
$mail->FromName = "My Name";
// 執行 $mail->AddAddress() 加入收件者,可以多個收件者
$mail->AddAddress("to@email.com","Josh Adams");
$mail->AddAddress("to2@email.com"); // optional name
$mail->AddReplyTo("jyu@aemtechnology.com","AEM");
$mail->WordWrap = 50; // set word wrap
// 執行 $mail->AddAttachment() 加入附件,可以多個附件
$mail->AddAttachment("path_to/file"); // attachment
$mail->AddAttachment("path_to_file2", "INF");
// 電郵內容,以下為發送 HTML 格式的郵件
$mail->IsHTML(true); // send as HTML
$mail->Subject = "testing email";
$mail->Body = "This is the HTML body";
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent ";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
CASE 2 aXXl
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->CharSet = "utf-8";
$mail->From = 'admin@XX.XX.X.X';
$mail->FromName = 'AXX';
$subject = " system email test";
$mail->Subject = $subject;
$data_user[0]['id']='xx@xx.xxxx';
$data_user[0]['name']='Bau';
$sql="";
$body = "Dear,
please reply to testing email.";
$data=lazy_get_data($sql);
foreach($data as $value){
$body.=$value['empID'].'gg'.$value['empEmail']."
";
}
//$mail->SingleTo=TRUE; #個人理解,如果cc有多個接收mail只會顯示一個人的
$mail->ClearAddresses(); #由於內文不一樣,$mail->AddAddress 的陣列讓寄信人只寄一個,避免寄給很多人。
// optional, comment out and test
$body = eregi_replace("[\]",'',$body);
$mail->MsgHTML($body);
$mail->Encoding = "base64";
foreach($data_user as $value){
$mail->AddAddress($value['id'], $value['name']);
$mail->IsSMTP();
$mail->SMTPAuth = false;
//$mail->Port = 25;
//需使用SMTP驗證
//ou$mail->SMTPSecure = "ssl";
// 利用SSL連線到伺服器
$mail->Host = "mail.global.frontbridge.com";
//當然啦,信件寄送主機就是GMAIL
//$mail->Port = 465;
//指定SMTP port
//$mail->Username = "";
//MAIL帳號
//$mail->Password = "";
if($debug=='1'){
echo "";
echo $mail->Subject."";
echo $to."[{$to_name}]";
echo $body;
}elseif($debug=='0'){
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
echo $to;
exit;
} else {
//echo "Message sent!";
sleep(3);
}
}
}
要注意Gmail 的 SMTP主機固定位址是 smtp.gmail.com,必須使用 465 埠以 SSL 的方式來連線
所以apache需要灌ssl才行。
2011年12月21日 星期三
mail template
有關於 mail裡面放css 需要 下註解,免得收件人看不到正確內容。
範例:
參考:
http://www.freegroup.org/2010/11/100-free-html-email-templates-with-psd-sources/
範例:
$body=""
參考:
http://www.freegroup.org/2010/11/100-free-html-email-templates-with-psd-sources/
unset( ) 刪除變數
語法 : int unset(mixed var);
說明 :參數 可放入多個參數。
unset()刪除指定的變數,且傳回true。
範例:
說明 :參數 可放入多個參數。
unset()刪除指定的變數,且傳回true。
範例:
$array=array("a"=>"卡卡","b"=>"黃金");
unset($array);
if(isset($array)){
print_r($array);
}else{
echo '沒有變數';
}
unset($a);
unset($b);
等於
unset($a,$b);
COUNT( ) 回傳筆數
SQL COUNT(column_name) Syntax
returns the number of values (NULL values will not be counted) of the specified column
The COUNT(*) function returns the number of records in a table:
尋找顧客ans購買次數:
returns the number of values (NULL values will not be counted) of the specified column
SELECT COUNT(column_name) FROM table_name
The COUNT(*) function returns the number of records in a table:
SELECT COUNT(*) FROM table_name
| O_Id | OrderDate | Price | 顧客 |
| 1 | 20011/11/12 | 100 | ans |
| 2 | 20011/11/12 | 100 | dce |
| 3 | 20011/11/14 | 100 | abc |
| 4 | 20011/11/15 | 100 | ans |
尋找顧客ans購買次數:
SELECT COUNT(顧客) AS CustomerNilsen FROM Orders
WHERE 顧客='ans'
2010年1月10日 星期日
firfox在網頁上的工具
Firefox 網頁設計擴充套件 Firebug (螢火蟲)
主要功能是即時監控 HTML、CSS、DOM 和 JavaScript 等的網站開發工具,
對於網頁製作與 CSS 設計是極大的幫手,
它擁有 CSS 與 JavaScript 除錯功能,
如果總是對 HTML 或 CSS 眼花,你將會愛上 Firebug
主要功能是即時監控 HTML、CSS、DOM 和 JavaScript 等的網站開發工具,
對於網頁製作與 CSS 設計是極大的幫手,
它擁有 CSS 與 JavaScript 除錯功能,
如果總是對 HTML 或 CSS 眼花,你將會愛上 Firebug
2010年1月6日 星期三
CSS版面設定
html引入css檔案
header底下的一個空白區格
<body></body>
CSS碼為:
CSS樣式:
1.內嵌樣式
2.利用 標籤
header底下的一個空白區格
<body></body>
studies
CSS碼為:
#pageheading {
font-size:3.25em;
font-weight:bold;
padding-top:20px;
color:#fff;
padding-bottom:20px;
}
#headingspacer{
margin:0 0 0 0;
height:22px;
background: url('images/XXX.gif') repeat bottom;
}
CSS樣式:
1.內嵌樣式
2.利用 標籤
3.@import 表示法
@import url(mysite.css);4.行內樣式-直接利用元件的 STYLE 屬性(缺點:無法被重複利用)
2010年1月5日 星期二
PHP的一些筆記
寫php寫if判斷式要改進的一些寫法,但不適合用在多行程式碼。
原式:
要改成:
加入else後:
經php處理後,反回前頁的script:
mail()的寄送:
截掉字串,放入指定空間:
substr(),mb_substr()及mb_strcut()這三個函數都是用來截取字串的。
算從db抓取資料的筆數:
(也可利用sql裡的count來算筆數)
php 頁面 utf-8 (ini_set utf-8)
mysql 亂碼,因為連線時沒有指定utf-8
方法:
mysql_query('SET NAMES utf8');
mysql_query('SET CHARACTER_SET_CLIENT=utf8');
mysql_query('SET CHARACTER_SET_RESULTS=utf8');
原式:
if($kk=="cc"){echo $hh--;}
要改成:
if($kk=="cc")$hh--;
加入else後:
if($kk=="cc")$hh--;else $kk++;
經php處理後,反回前頁的script:
" alert//('已寄發通知信');history.back();";
mail()的寄送:
function SendHtmlMail($mail_info)
{
$from_address = $mail_info["from_address"];
$to_address = $mail_info["to_address"];
$message = $mail_info["message"];
$subject = $mail_info["subject"];
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: ".$from_address."\r\n";
$headers .= "Reply-To: ".$from_address."\r\n";
if(@mail($to_address, $subject, $message, $headers)) echo "成功"; else echo "失敗";
}
--------------------------以上是自訂函數----------------
$subject->標題
$mail_info["subject"] = "=?UTF-8?B?" . base64_encode($subject) . "?=";
$mail_info["message"] ="來blog看看";
$mail_info["from_address"] = "from mail";
$mail_info["to_address"] = "to mail";
SendHtmlMail($mail_info);
截掉字串,放入指定空間:
//此函式用來將文字截斷成某個固定長度,並示意還有更多
function truncate_text_nicely($string, $max, $moretext){
//字中超過所設定的最大長度才會進行處理
if (strlen($string) > $max){
//修正$max,減去省略符號的長度以騰出更多空間
$max -= strlen($moretext);
//只擷取字串合適的部分
$string=strrev(strstr(strrev(substr($string, 0, $max)),' '));
//將省略符號加到後面
$string .=$moretext;
}
//不管字串有沒有變動,都將它傳回去
return $string;
}
$str='It was a dark and stormy night when the Baron prepared his plane.';
$str1="今天上班看到路上有很多明華園要公演的旗幟";
//將字串解析成為值
$values=truncate_text_nicely($str1,35,'...');
echo "
{$values}
";
因為某些原因,想要截取字串。一開始想到的是 mb_strcut()。
如果要取某個字串的前 10 字,可以這樣下:
$text = "許茹芸淚海慶功宴吃蓋飯在台北市四平街";
$result = mb_strcut($text, 0, 30, "UTF-8");
echo $result; // 許茹芸淚海慶功宴吃蓋
但是要取某個字串的「後 10 字」呢?
最一開始的想法是用 mb_strlen() 把 $text 的長度取出來,但是後來發現其實 mb_strcut() 本身就支援這個做法:
$text = "許茹芸淚海慶功宴吃蓋飯在台北市四平街";
$result = mb_strcut($text, -30, 30, "UTF-8");
echo $result; // 吃蓋飯在台北市四平街
Tags: php mb_strcut mb_strlen 字串 長度 截取 UTF-8 utf8 許茹芸 淚海 慶功宴 蓋飯 四平街
substr(),mb_substr()及mb_strcut()這三個函數都是用來截取字串的。
echo mb_substr('字不要切一半我字不要切我字, 0, 7, 'utf-8');
輸出:字不要切一半我
echo mb_substr('字a不要切c一半我字不要切我字', 0, 7, 'utf-8');
輸出:字a不要切c一
echo mb_strcut('字不要切一半我字不要切我字', 0, 7, 'utf-8');
?>
输出:字不
從上面的例子可以看出,mb_substr是按字來切分字符,而mb_strcut是按字節來切分字符,但是都不會產生半个字符的現象,也就是亂碼的現象。
算從db抓取資料的筆數:
(也可利用sql裡的count來算筆數)
$sql="select * from XXX where XXX='$XXX'"; $result=mysql_query($sql); $count_result=mysql_num_rows($result);
php 頁面 utf-8 (ini_set utf-8)
ini_set('default_charset', 'utf-8');
mysql 亂碼,因為連線時沒有指定utf-8
方法:
mysql_query('SET NAMES utf8');
mysql_query('SET CHARACTER_SET_CLIENT=utf8');
mysql_query('SET CHARACTER_SET_RESULTS=utf8');
2008年2月23日 星期六
php分頁
程式端相關程式:
相關提要,此分頁範例為新聞,會有相關的類別,在切換類別時又會有分頁的問題。
比如說 政治這個類別 又15筆資料,當$p為10就會產生分頁,會有 [1][2]需要切換。
到時就需要借助cat 這個變數。那cat這個變數會有兩種方式丟出(POST及GET)
以下為副程程式:
相關提要,此分頁範例為新聞,會有相關的類別,在切換類別時又會有分頁的問題。
比如說 政治這個類別 又15筆資料,當$p為10就會產生分頁,會有 [1][2]需要切換。
到時就需要借助cat 這個變數。那cat這個變數會有兩種方式丟出(POST及GET)
$p=10; //每頁顯示10筆
$px=5; //每頁顯示跳頁用的5筆
$col_id=intval($_GET['cat']); //get
$post_kind_id=$_POST['kind_id'];//post
if($post_kind_id!=''){
$col_id=$post_kind_id;
$page=""; #避免之前選擇的頁數影響之後post出去的page頁面
$sql_where_kind=" where kind_id='$col_id'";
$sql="SELECT * FROM `".DBPREFIX."_news` ".$sql_where_kind;
$data=lazy_get_data($sql);
}else{
$data=lazy_get_data($sql);
}
if($col_id!=""){
$sql_where_kind=" where kind_id='$col_id'";
$sql="SELECT * FROM `".DBPREFIX."_news`".$sql_where_kind;
$data=lazy_get_data($sql);
}
$snStr="issue_news.php?cat={$col_id}";
$total =$num;
$show=ceil($total/$p); //每頁顯示$P筆
if(isset($page)){
$page=$page;
}else if(isset($_GET['page']))
{
$page=$_GET['page'];
}else{
$page=0;
}
$sqlproducts=$sql. " ORDER BY top_sn desc ,news_sn desc "." LIMIT ".($page*$p).",".$p;
$data=lazy_get_data($sqlproducts);
//放在table最下面
array_page($total,$page,$p,$px,$snStr);
以下為副程程式:
一、只要給這支function資料庫的總筆數(用count去算就好了)
二、原本的select查詢,最後面加上limit ".($page*$p).",".$p;
三、在表格最後面,把function這個名字貼上
array_page($totals_rows,$page,$p,$px,$new_Link);
四、$new_Link就是要該網頁,原本有些 $_GET 要回傳,就加在這裡...
例如:http://localhost/test.php?mode=old ---> 查歷史資料 $new_Link 就
給他 'mode=old'
山人覺得優點就是...
database用 limit 去限制每次查的大小,可以節省資料庫抓資料數量的負擔
用count去算database的內容也快
原本的SQL語法如...
$sql="select id,name,sex from humandata";
要改成二支
一支如第二點所說的 :
$sql="select id,name,sex from humandata limit ".($page*$p).",".$p;
另一支就是要算筆數
$sql="select count(*) from humandata";
或擔心二支SQL算出不用筆數,就偷懶這樣寫
$sql="select count(*) from (原sql語法) as a ";
接著...$totals_rows=mysql_result(mysql_query($sql),0,0);
一點點小小的心得供大家參考...也希望大家能多多指教
//自動產生分頁排序說明
//版本1.1
//開發者:羽山秋人
//時間:2007414
//第二版修正於:2007416
//使用方法
/* array_page(
$totals_rows $資料庫算出的總筆數,
$page $目前的頁碼常用
$p $每頁顯示的筆數
$px $每頁要顯示多少個【第 xx 頁】
$new_Link $跳頁用的網頁帶入值 ---> ?以後原本傳的值
P.S:需自行在 SQL 語法最後加上 limit ".($page*$p).",".$p;
P.S:$p、$px、$page 請加注在 檔案開頭 以上
limit ".($page*$p).",".$p; //加在原本沒分頁的SQL語法最後(mysql only)
//要加開網頁開頭的部分-------------------start
$p=10; //每頁顯示5筆
$px=5; //每頁顯示跳頁用的5筆
if(isset($page))
{
$page=$page;
}
else if(isset($_GET['page']))
{
$page=$_GET['page'];
}
else
{
$page=0;
}
//要加在網頁開頭的部分-------------------end
*/
function array_page($totals_rows,$page,$p,$px,$new_Link)
{
//傳說中的分頁
//$p=5; // 每頁顯示5筆
//$px=5; //每頁限制最多5頁,超過就用「下5頁」上5頁
$page_range_start=floor($page/$px)*$px;
$page_range_end=$page_range_start+$px;
//自動算幾頁
$totals_page=ceil($totals_rows/$p);
if($page_range_end>$totals_page)
{
$page_range_end=$totals_page;
}
//echo $page_range_start;
//echo "
";
//echo $page_range_end;
//echo "
";
if($page-($page%$px)>=$px)
{
echo "【上".$px."頁】 ";
}
if(($page-$page%$px)<$totals_page-$px)
{
if(($page+$px)>=$totals_page) //修正加上page的頁碼超過最終頁碼 2007/4/16
{
$temp=$totals_page-1;
}
else
{
$temp=$page+$px;
}
echo "【下".$px."頁】";
}
echo "
";
for($i=$page_range_start;$i<$page_range_end;$i++)
{
if($page==$i)
echo "【第 ".($i+1)." 頁】";
else
echo "【第 ".($i+1)." 頁】";
}
echo "
第【".($page+1)."】頁";
echo "合計共【".$totals_rows."】筆/共【".$totals_page."】頁";
//分頁結束
}
?>
2008年1月16日 星期三
物件
//seal類別
class seal {
//屬性
public $name;
public $shape;
public $diameter;
public $length;
//建構子
function __construct($name,$shape,$diameter,$length) {
$this->name=$name;
$this->shape=$shape;
$this->diameter=$diameter;
$this->length=$length;
}
public function stamp()
{
echo "(印)".$this->name."\n";
}
}
header("Contet-type:text/plain;charset=big5");
//建立實體
$obj=new seal("高島","圓柱",10,60);
//屬性
echo"私的印章的形狀是「".$obj->shape."」\n";
//方法
$obj->stamp();
列出已被定義函數、變數
header("Content-Type:text/plain; charset=big5");
if(function_exists("mb_send_mail")){
echo "mb_send_mail函式已定義";
}else{
echo "mb_seind_mail函式沒定義";
}
print_r(get_defined_functions());/*列出已被定義的函數 */
print_r(get_defined_vars());/*列出已定義的變數 */
2008年1月6日 星期日
array_map(PHP函式)
說明
傳入參數:參數1是使用者自定的函式(callback function)的名稱,參數2到n是陣列型態的參數。
基本說明:依照使用者自定的函式,對陣列的元素組做處理。
結果:
Example#2 array_map() - using more arrays
結果
array array_map (mix callback , array $arr1 [, array $... ] )傳入參數:參數1是使用者自定的函式(callback function)的名稱,參數2到n是陣列型態的參數。
基本說明:依照使用者自定的函式,對陣列的元素組做處理。
function cube($n){
return($n * $n * $n);
}
$a = array(1, 2, 3, 4, 5);
$b = array_map("cube", $a);
print_r($b);
結果:
Array
(
[0] => 1
[1] => 8
[2] => 27
[3] => 64
[4] => 125
)
Example#2 array_map() - using more arrays
function show_Spanish($n, $m)
{
return("The number $n is called $m in Spanish");
}
function map_Spanish($n, $m)
{
return(array($n => $m));
}
$a = array(1, 2, 3, 4, 5);
$b = array("uno", "dos", "tres", "cuatro", "cinco");
$c = array_map("show_Spanish", $a, $b);
print_r($c);
$d = array_map("map_Spanish", $a , $b);
print_r($d);
結果
// printout of $c
Array
(
[0] => The number 1 is called uno in Spanish
[1] => The number 2 is called dos in Spanish
[2] => The number 3 is called tres in Spanish
[3] => The number 4 is called cuatro in Spanish
[4] => The number 5 is called cinco in Spanish
)
// printout of $d
Array
(
[0] => Array
(
[1] => uno
)
[1] => Array
(
[2] => dos
)
[2] => Array
(
[3] => tres
)
[3] => Array
(
[4] => cuatro
)
[4] => Array
(
[5] => cinco
)
)
簡易資料驗證(javascript)
<HTML>
<HEAD>
<TITLE>簡易資料驗證</TITLE>
<script language="javascript">
function myFunction(){
try{
if(document.myForm.ID.value !="test"){
throw "idError"
}else if(document.myForm.psw.value !="test"){
throw"pswError"
}else{
alert("身份驗證通過")
}
}catch(e){
if(e=="idError")alert("帳號資料不符")
if(e=="pswError")alert("密碼資料不符")
}
}
</script>
</HEAD>
<BODY >
<center>
進入會員專區前,請先登入:<BR>
<form name="myForm">
帳號:<input type="text" name="ID" size="10"><br>
密碼:<input type="password" name="psw" size="10"><br>
<input type="button" value="身份驗證" onClick="myFunction()">
</form>
</BODY>
</HTML>
2007年1月19日 星期五
下載YouTube影片加轉檔
Step1.先找到,你要下載的影片。

step2.然後複製影片網址。

step3.接著就要下載下來囉,不過,需要使用這http://keepvid.com/
來下載youtobe的影片then存成*.flv。



step4.接著就是用程式把*.flw轉成wmv檔囉。當然,你也可以用...LV Playe看啦.
使用CinemaForge 2.0.5
(http://www.download.com/CinemaForge/3000-2169_4-10373646.html)




OK啦~
step2.然後複製影片網址。
step3.接著就要下載下來囉,不過,需要使用這http://keepvid.com/
來下載youtobe的影片then存成*.flv。
step4.接著就是用程式把*.flw轉成wmv檔囉。當然,你也可以用...LV Playe看啦.
使用CinemaForge 2.0.5
(http://www.download.com/CinemaForge/3000-2169_4-10373646.html)
OK啦~
2006年6月28日 星期三
DVD 轉成mpg
使用 DVD Decrypter把dvd影音光碟裡的資料全抓到硬碟裡(SetupDVDDecrypter_3.5.4.0.exe)

使用DVD2AVI (DVD2AVI_1.9rc5)

檔案-->開啟-->選擇檔案(之前把dvd拉到硬碟的資料夾)-->選擇*.vob-->開啟
-->(回到主畫面後)-->檔案-->儲存專案檔-->key入檔名(副檔名 *.d2v)-->儲存
ps.這個動作會產生一個*.d2v 及一個聲音檔(*.mpa)
使用VFAPIConv-1.05-EN這個資料夾
安裝動作:執行vifpset.bat(執行一次就行了)
執行vfapi(VFAPIConv.exe)這程式


左下角(Add Job)-->選擇之前產生的*.vob-->ok-->convert
ps.這動作會產生一個影像檔。
使用TMPGEnc [TMPGEnc Plus-2.54.37.135_cht(破解)]
這動作是把影像檔跟影音檔結合轉成mpg
執行:TMPGEnc.exe

使用DVD2AVI (DVD2AVI_1.9rc5)
檔案-->開啟-->選擇檔案(之前把dvd拉到硬碟的資料夾)-->選擇*.vob-->開啟
-->(回到主畫面後)-->檔案-->儲存專案檔-->key入檔名(副檔名 *.d2v)-->儲存
ps.這個動作會產生一個*.d2v 及一個聲音檔(*.mpa)
使用VFAPIConv-1.05-EN這個資料夾
安裝動作:執行vifpset.bat(執行一次就行了)
執行vfapi(VFAPIConv.exe)這程式
左下角(Add Job)-->選擇之前產生的*.vob-->ok-->convert
ps.這動作會產生一個影像檔。
使用TMPGEnc [TMPGEnc Plus-2.54.37.135_cht(破解)]
這動作是把影像檔跟影音檔結合轉成mpg
執行:TMPGEnc.exe
2006年6月26日 星期一
使用千千靜聽- step by step
軟體介紹網站:
http://toget.pchome.com.tw/intro/multimedia_musicplayer/24184.html
http://linshi.twbbs.org/blog/tsairg/67153
圖解:






*最後的一個步驟需要注意~千萬不要勾到"百度搜索伴侶",因為會造成很多困擾
http://toget.pchome.com.tw/intro/multimedia_musicplayer/24184.html
http://linshi.twbbs.org/blog/tsairg/67153
圖解:
*最後的一個步驟需要注意~千萬不要勾到"百度搜索伴侶",因為會造成很多困擾
訂閱:
文章 (Atom)












