2012年11月2日 星期五

[文章標題]在近N天的標題後加一個new的icon

function new_image($s_time){
  $tc=(date('U',time())-date("U",strtotime($s_time)))/86400;
  $tc_image_new='';
 if($tc<=3)
  $tc_image_new="";
      
  return $tc_image_new;
}

PS. 一天86400秒

icon finder: http://www.iconfinder.com/

您可能有興趣的書單:

2012年9月27日 星期四

php excel

EXCEL讀檔 寫入MYSQL

include_once("../XXX/phpexcel/PHPExcel/IOFactory.php");
include_once('../XXX/phpexcel/PHPExcel/Reader/Excel5.php');
 if($_FILES['employeeData']['name']=="" )"ERROR!!no FILE!!";

 $reader = new PHPExcel_Reader_Excel5;
 $PHPExcel=$reader->load($_FILES['exployxeData']['tmp_name']);
 $sheet=$PHPExcel->getSheet(0);
 $highestRow=$sheet->getHighestRow();

for($row=1;$row<=$highestRow;$row++){
 //echo $i."$$";
 $str='';
  for($column=0;$column<=6;$column++){
   $aa=$sheet->getCellByColumnAndRow($column,$row)->getvalue();
    $temp[$column]=$aa;
    if($column=='0'){
     $str.="'".$aa."',";//id
     $str.="'".$aa."',";//pwd
    }elseif($column=='6'){
     if($temp[4]==$temp[0]){
      $str.="'1',";   
     }elseif($temp[6]=='1'){
      $str.="'2',";
     }else{
      $str.="'0',";
     }
     
    
    }elseif($column=='5'){
     continue;
    }else{
     if($aa!=''){
      $str.="'".$aa."',";
     }
    }
   
  }
   
   $str=substr($str,0,strlen($str)-1);
   
   
  if($row>1){
   $sql="insert into Base  (`ID`,`Pwd`,`Name`,`Name`,`Email`,`lID`,`role`)values($str)";
   mysql_query($sql);
   
   if(! mysql_affected_rows()>0){
    echo "error:name:{$temp[1]}";
    exit;
   }
  }
 }

寫入excel
include_once("../class/phpexcel/PHPExcel/IOFactory.php");

$path="../download/";
 $objRD=PHPExcel_IOFactory::createReader("Excel5");
 
 $objExcel=$objRD->load($path."temp.xls");
 //$CobjExcel=new PHPExcel();

 //$objExcel=$CobjExcel->load($path."temp.xls");
 
 $objExcel->setActiveSheetIndex(0);
 $sheet=$objExcel->getActiveSheet();

 for($i=1;$i<$num;$i++){
  //if($data[$i]['enable']==0) continue; #因為sql裡面排除不了enable為0的,所以做此處理
         $sheet->setCellValueByColumnAndRow(0,$colum,$searchContent[$i]['userName']);
  $sheet->setCellValueByColumnAndRow(1,$colum,$searchContent[$i]['ID']);           
  $sheet->setCellValueByColumnAndRow(2,$colum,$searchContent[$i]['shifName']);
$colum++;
  }
  
  
  $objExcel=PHPExcel_IOFactory::createWriter($objExcel,'Excel5');

  $filePath=$path."labor_hour.xls";
  $objExcel->save($filePath);
  
  
  dl_file($filePath);  

2012年9月24日 星期一

關閉視窗

<script type='text/javascript'>

function windows_close(){
 window.open('','_parent','');  
 window.opener = null;
 window.open('','_parent','');
 window.close();
}
</script>

<input type='button' onclick='windows_close()' value='關閉視窗'>
ex-2
<script type='text/javascript'>
 function doClose(){this.close();}
</script>

2012年9月18日 星期二

javascript 時間

時間:
建立Date 物件
today=new Date();
//出來的是 Wed Sep 19 2012 14:41:42 GMT+0800(台北標準時間)

Date的三種用法
物件名稱=new Date()
物件名稱=new Date("月 日,年 時:分:秒");
物件名稱=new Date (年,月,日,時,分,秒);

使用物件的方法
取得
getYear()
getMonth()
getDate()
getDay()
getHours()
getMinutes()
getSeconds()
設定
setYear()
setMonth();
setDate();
setHours();
setMinutes();
setSeconds();

today.getTime();
出來的是unix的秒數

2012年8月21日 星期二

針對某個瀏覽器做css的調整(瀏覽器視窗高度)

判別瀏覽器:
jQuery.browser.version
jQuery 提供了 browser 物件來讓我們能判斷現在的訪客是用什麼瀏覽器及版本

可參考 [jQ]jQuery.browser.version 在 IE 中版本判斷的 Bug

判斷是否為ie瀏覽器 可以使用:$.browser.msie


[JQuery][轉錄] 如何取得瀏覽器視窗高度及寬度 (跨瀏覽器)

2012年8月9日 星期四

列印

<script type="text/javascript">
function printScreen(block){
var value = block.innerHTML;
var printPage = window.open("","printPage","");
printPage.document.open();
printPage.document.write("<HTML><head></head><BODY onload='window.print();window.close()'>");
printPage.document.write("<PRE>");
printPage.document.write(value);
printPage.document.write("</PRE>");
printPage.document.close("</BODY></HTML>");
}
<javascript">
<input type='button' value='列印' style="color:#F00; font-size:12px" onclick="printScreen(showOneOrderDetail)"/>

<div id='showOneOrderDetail'>
......
</div>

2012年7月30日 星期一

PDO

PHP 從 PHP5 開始,在資料庫操作方面新增了 PDO(PHP Data Objects)的 extension,利用物件導向的方式與資料庫進行溝通。捨棄以往透過單一函式的方式,而是透過物件導向程式設計的抽象化概念,操作時使用統一的方法,如果需要更換資料庫時,只要在建立物件時給予資料庫的形式,而不用更動到原來的程式碼。這也是物件導向程式設計擁有優良靈活性的最佳表現!

連線方法:

try {
/**
* The PDO String connection is for mysql
* Check the documentation for your database
*/
$db = new PDO(
'mysql:host=localhost;dbname=vhost24579-4',
'root',
'pwd'
);
/** As I am brazilian I always use UTF-8 enconding
* in files, connections and charset
*/
$db->query("SET NAMES UTF8");

} catch ( PDOException $e ) {

print "Error!: " . $e->getMessage() . "<br/>";
die();

}

<?php

// 組合 SQL 語法,取得符合 id = 2、name = 'John' 的資料

$sth = $dbh->prepare('SELECT * FROM table WHERE id = :id AND name = :name');

$where = array(':id' => 2, ':name' => 'John');

// 使用 execute(),會自動 quote $where 的參數

$sth->execute($where);



foreach ($sth->fetchAll(PDO::FETCH_ASSOC) as $row) {

print_r($row);

}

?>

範例1:

// 利用迴圈對每一列做處理
$dataArray = array(); // 結果儲存陣列
while ($row = $stmt->fetch(PDO::FETCH_ASSOC) {
// 資料處理
$row['colour'] = $row['colour']? $row['colour'] : '#000';
// 加儲存陣列
array_push($dataArray,$row);
}

2012年7月29日 星期日

Text Box 美化

css:
行內 style
style="border-bottom: #27b3fe 1px solid; border-left: #27b3fe 1px solid; margin-top: 2px; width: 105px; margin-bottom: 3px; background: url(../images/store/login_6.gif) #ffffff repeat-x; height: 20px; border-top: #27b3fe 1px solid; border-right: #27b3fe 1px solid;"

-moz、-ms、-webkit代表什麼意思呢?


-moz代表firefox瀏覽器私有屬性
-ms代表IE瀏覽器私有屬性
-webkit代表chrome、safari瀏覽器私有屬性
,,,,,
class宣告方式為 .classname
id 宣告方式為 #idname
tag 宣告方式為 tagname
,,,,,
ID 選擇器在一個 HTML 文件中只能被使用一次
Class 選擇器在一個 HTML 文件中可以被使用多次
Tag 選擇器只的是HTML文件中所有的標籤 

lession1 
lession2
lession3

2012年7月26日 星期四

簡單的MySql class

引用:http://www.phpclasses.org/package/7572-PHP-Setup-MySQL-database-connections.html
<?php
////////////////////////////////////////////
//@Product Name : Connect to MySQL Class //
//@Coding By : hossam Youssef //
//@Copyright © 2010 - 2012 //
////////////////////////////////////////////

// Class
class database {
public $db_host;
public $db_user;
public $db_pass;
public $db_name;

// That to start connection with MySQL
function db_connect(){
// connect with MySQL
$connect = @mysql_connect($this->db_host,$this->db_user,$this->db_pass);
if(!$connect){
@mysql_close($connect);
die ("<h1><font color='#000000'><center>MySQL DataBase Not<font color='#FF0000'style='text-decoration:blink;'> Connected !</font></center></font></h1>");
return false;
}
return true;
}

// Here you have select database with MySQL
function db_select(){
// Select with Database
$select = @mysql_select_db($this->db_name);
if(!$select){
@mysql_close($connect);
die ("<h1><font color='#000000'><center>Not <font color='#FF0000'style='text-decoration:blink;'>Selected</font> DataBase !</center></font></h1>");
return false;
}
return true;
}

// Here you select charset UTF8 with Database
function charset_UTF8(){
// MySQL connection collation UTF8
@mysql_query("SET names 'UTF8'");
@mysql_query("SET charset 'UTF8'");
@mysql_query("SET character_set_client = UTF8");
@mysql_query("SET character_set_connection = UTF8");
@mysql_query("SET character_set_database = UTF8");
@mysql_query("SET character_set_results = UTF8");
@mysql_query("SET character_set_server = UTF8");
}

// MySQL Close connect Function
function close(){
global $connect;
@mysql_close($connect);
}
}

// start show
$db = new database();
/* The hostname of the MySQL server */
$db->db_host = "localhost";
/* The username to login to MySQL */
$db->db_user = "root";
/* The password to login to MySQL */
$db->db_pass = "123";
/* The name of the MySQL database */
$db->db_name = "tesr";

// Call class
$db->db_connect();
$db->db_select();
$db->charset_UTF8();

// Close connect
//$db->close();
?>

同場加映:人生是永遠的測試版:新創企業家改寫生涯的方程式

2012年7月19日 星期四

如何表達同意或反對

WHAT TO SAY...: When You Agree or Disagree (Part 1 of 5) 如何表達同意或反對?

We all love it when others agree with our opinions, plans or decisions. Likewise, we enjoy supporting our friends with the same enthusiasm. Sooner or later, though, each of us faces disagreement. People don't always agree with us, and we may not see eye-to-eye with them either. Whether we agree or disagree, knowing how to express ourselves effectively makes a big difference.

How confident do you feel about knowing what to say when you agree? Here is a list of good phrases to use to agree.

(Formal)  I agree completely.

That's just what I think.

(Informal) You're right, of course.

I think so, too. Sure.

我們都喜歡別人贊同自己的觀點、計畫或決定。同樣地,我們也喜歡以這份熱忱來支持我們的朋友。不過遲早,我們都要面對意見不合的情況。別人不會總是贊同我們,我們也不會與他們持相同看法。不論我們同意或反對,知道如何有效地表達自己的意見,會帶來不同的結果。

當你同意別人時,你有多少把握知道自己該說些什麼?這裡有一些好句子可用來表示贊成。

(正式用語)  我完全同意。

那正是我所想的。

(非正式用語) 當然,你是對的。

我也這麼認為。

對啊!

enthusiasm (n) 熱忱; 熱心

WHAT TO SAY...: When You Agree or Disagree (Part 2 of 5) 如何表達同意或反對?

(after school)

Mary: Wow! Did you see Sarah's new haircut? I've never seen her with short hair before. It looks great!

Jane: I couldn't agree more! She looks so sophisticated. Seeing her makes me want to get my hair cut, too.

Mary: Me, too! Let's experiment with a comb and mirror to see which length looks best. Then, we can make appointments for cuts at the beauty parlor on Saturday.

會話一

(放學後)

瑪麗:哇!你看到莎拉的新髮型了嗎?我以前從來沒看過她留短頭髮,實在很好看!

珍 :我非常贊成!她看起來好成熟。看著她讓我也想去剪短頭髮呢!

瑪麗:我也是!我們來用梳子和鏡子試試,看哪個長度最適合,然後我們就和美容院約個星期六去剪頭髮。

sophisticated (adj) 成熟的; 老練的

beauty parlor (n phr) 美容院

WHAT TO SAY...: When You Agree or Disagree (Part 3 of 5) 如何表達同意或反對?

At times a person may not be ready to agree, yet hesitates to disagree strongly. In this situation, using an indirect approach is more effective. It usually results in the positive exchange of information and avoids conflict. It is also more polite than a direct approach. Sometimes more formal expressions are called for, such as in disagreements with a supervisor. Close friends can more easily use informal words without damaging their relationship. Here are some useful phrases to use when you don't agree.

(Formal)   I'm not sure I agree.

Are you absolutely sure?

I may be wrong, but . . .

(Informal)  Oh, I don't know . . .

Yes, but . . .

Really?

有的時候,別人可能不很贊同,卻又猶豫不願意強烈地反對。在這種情況之下,採用間接的方式會比較有效。如此通常會帶來一種正面的意見交換,而又避免衝突。它也比直接的方式更有禮貌。有的時候正式的表達是需要的,例如,和你的上司持相反意見時。好朋友間則較容易用不拘小節的字眼,而不傷害彼此的關係。這裡有一些很實用的句子來表達反對。

(正式用語)  我不確定我贊成。

你真的那麼確定嗎?

我可能不對,但是…

(非正式用語) 嗯,我不知道耶…

對啊,但是…

真的嗎?

hesitate (v) 猶豫; 躊躇

approach (n) 方法; 步驟

conflict (n) 爭執; 意見抵觸

absolutely (adv) 完全地; 肯定地

WHAT TO SAY...: When You Agree or Disagree (Part 4 of 5) 如何表達同意或反對?

Hank: I'm really looking forward to the movie on Saturday. It will be great to see Mel Gibson again. He was so cool in Sleepless in Seattle!

Sharon: Are you sure Mel Gibson was in that one? I thought it was Tom Hanks.

Joan: Me, too. I may be wrong, but wasn't Mel Gibson the lead in Braveheart?

Hank: Well, maybe you're right. I have the Sleepless in Seattle video at home. I'll check.

Sometimes you may have strong feelings against an idea or opinion. Although it is difficult, you can disagree directly if you handle it in the proper way. Try phrases from the following list to help. It's usually best to include a reason for opposing what the other person has said.

(Formal)   I'm sorry, but I have to disagree.

I strongly disagree.

I refuse to believe that . . .

(Informal)  No, that's wrong.

You're dead wrong.

Nope!

會話二

漢克:我真的很期待星期六要去看的那部電影。再看到梅爾.吉柏遜一定很棒!他在「西雅圖夜未眠」裡好酷喔!

雪倫:你確定梅爾.吉柏遜有演那部電影嗎?我以為是湯姆.漢克斯。

瓊 :我也這麼想。我可能錯了,不過梅爾.吉柏遜不是那個主演「英雄本色」的嗎?

漢克:嗯,可能你們說的對。我家裡有「西雅圖夜未眠」的錄影帶,我會再確定一下。

有時你可能很強烈地反對一個主張或意見。雖然直接提出反對意見很困難,但是如果處理得當,仍然可行。試試看下面的句子。通常,不贊成時最好能提出不贊成對方所說的理由。

(正式用語)  我很抱歉,但我必須反對。

我非常不贊成。

我不願意相信…

(非正式用語) 不,那是錯的。

你大錯特錯了。

不對!

oppose (v) 反對

WHAT TO SAY...: When You Agree or Disagree (Part 5 of 5) 如何表達同意或反對?

Tom: Hey! Look! Someone dropped their wallet. It has some money. We can share it and get a snack at McDonald's!

George: No way! That would be like stealing. Let's look to see if the owner's name and address are inside. We should return it.

Tom: Are you crazy? We found it. We should keep it.

George: I disagree. Maybe the owner will be so glad to have it back he will give us a reward. Then we will know we've done the right thing, and we'll have money for a snack.

Tom: Well, OK. Maybe your plan is better.

Activities

With a friend, practice agreeing and disagreeing in the following situations:

1. You and a friend have just come from the art museum. Both of you agree that the paintings by a new artist are the best you've ever seen.

2. You and a friend are going across town to a movie. You want to go by bus, but your friend insists that a taxi is best.

3. You are planning a vacation with your husband (or wife). You want to go to the beach, but your spouse wants to go to the mountains.

會話三

湯姆:嘿!你看!有人掉了皮夾,裡面還有一些錢。我們可以把它分了,去麥當勞買點心吃。

喬治:不可以!那就像偷竊啦!我們來看看失主的名字和地址有沒有在裡面。我們應該歸還它。

湯姆:你瘋了嗎?是我們發現它的,我們應該可以留下它。

喬治:我不同意。也許這位失主會因為找回皮夾很高興,而給我們獎賞。那我們就知道這件事作對了,而且我們也會有錢吃點心。

湯姆:唉,好吧,或許你的計畫比較好。

練習:

和朋友練習在下列情況下,表達相同或不同的意見:

1. 你和一位朋友剛從美術館裡出來。你們都認為一位新出道畫家的畫,是你們看過最好的作品。

2. 你和一位朋友要到城的另一頭看電影。你想搭公車,可是你的朋友堅持搭計程車。

3. 你正計畫和先生(或太太)共度假期。你想要去海邊,可是你的配偶想去山上。

insist (v) 堅持

spouse (n) 配偶

沖浪的過程是斷在哪的DOS指令

說明:可顯示封包在IP網路經過的路由器的IP位址。

Linux系統:tracepath

Windows系統:tracert

用法範例:

在DOS視窗(命令提示字元)中輸入: tracert tw.yahoo.com

範例:
在上限 30 個躍點上
追蹤 tw.frontpage.g03.yahoodns.net [119.160.246.241] 的路由:
1 7 ms 7 ms 7 ms h254.s98.ts.hinet.net [168.95.98.254]
2 16 ms 9 ms 7 ms h254.s98.ts.hinet.net [168.95.98.254]
3 6 ms 7 ms 6 ms caw1-3301.hinet.net [168.95.128.30]
4 14 ms 14 ms 13 ms 220-128-28-90.HINET-IP.hinet.net [220.128.28.90]
5 14 ms 14 ms 14 ms SKC1-3011.hinet.net [220.128.24.74]
6 16 ms 15 ms 15 ms TPDT-3011.hinet.net [220.128.1.114]
7 14 ms 13 ms 13 ms TPDT-3301.hinet.net [220.128.3.137]
8 16 ms 82 ms 15 ms 211.22.41.45
9 15 ms 15 ms 16 ms te-8-1.bas1-1-prd.tw1.yahoo.com [119.160.240.1]
10 14 ms 14 ms 15 ms w1.www.vip.tw1.yahoo.com [119.160.246.241]

追蹤完成。

acer error Warning ! your chass is has been Opened

原因:因為打開過側蓋,而電腦卻判斷你的側蓋沒關上,試過好幾次卻都沒有辦法關的很緊,只好把這功能關掉了。

解法:

1.開機後按下[Del]進入[BIOS]
2.進入[BIOS Security Features]選項
3.將[Chassis Opened Warning]選項由原本的[Enable]改為[Disabled]即可


2012年7月18日 星期三

Convert CSS into programmable CSS with LESS syntax

This class can convert CSS into programmable CSS with LESS (Leaner CSS) syntax.

It can parse a given CSS style sheet and extract certain common property constant values to turn them into variables in the converted output using LESS .

Currently it turns the CSS properties into LESS variables: color, width, height, font-family and font-size.

include_once 'css2less/class.css2less.php';

# sample: creates less source

$css = <<< EOD
#sidebar {
  padding: 0;
  margin: 0;
  font-size: 11px;
  width: 217px;
  position: absolute;
  top: 45px;
  left: 0;
  background-color: #EFEFEF;
  color: #444;
}

#sidebar h3 {
  clear: both;
  padding: 0;
  font-size: 12px;
  font-weight: bold;
}

#sidebar input[type='text'],
#sidebar input[type='password'],
#sidebar textarea {
  width: 186px;
  padding: 6px 5px;
  color: #626262;
  font-family: "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", "Luxi Sans", Tahoma, sans-serif;
  font-size: 1em;
  border: 1px solid #CCC;
  box-shadow: inset 0 1px 3px #E4E4E4;
}

EOD;

$cls = new CSS2LESS($css);
$less = $cls->convert();
echo sprintf('<pre>%s</pre>
', $less);


範例:/test/css2less_sample.php

基本選擇器

* $('*')
獲取檔案中的所有元素(包括html, head, body, etc)。
$('*')
$('#all *') id="all"的所有后代元素

#id $('#id')
根据指定的ID属性匹配一个元素。也可以结合CSS选择器的规则获取元素。

$('#id')
$('#id_1, #id_2') id="id_1"和id="id_2"的元素
$('#id_1 #id_2') id="id_1"的元素包含id="id_2"的元素

element $('element')
根据给定的元素名获取所有元素

$('div')

.class $('.class')
根据给定的类名获取所有元素(多个元素可以拥有相同的类名,一个元素可以有多个类名)

$('.class')

$('selector1, selector2, selectorN')
合并给定选择器的结果并返回,selector必须是合法的jQuery选择器。

$('div, #id, p.class')


2012年7月17日 星期二

滑鼠滑過去(文字)就變色

  a:link, a:visited, a:hover, a:active{
    text-decoration:underline;
    color:#6a5acd;
    background-color:transparent;
  }
另一個範例:
  a:link, a:visited{
    text-decoration:underline;
    color:#6a5acd;
    background-color:transparent;
  }
  a:hover, a:active {
    text-decoration:underline overline;
    color:#191970;
    background-color:#c9c3ed;
  }

程式專案架構

檔案結構:
AndroidManifest.xml
src/ (資料夾)原始碼(source)
gen/ (資料夾)自動生成
res/ (資料夾)資源

2012年7月16日 星期一

系統架構-應用程式

Android以Linux為核心的Android行動平台,使用Java作為程式語言,使介面到功能,都有層出不窮的變化,其中Activity等同於J2ME的MIDlet,一個Activity類別負責建立視窗,一個活動中的Activity就是在foreground(前景)模式,背景執行的程式叫做Service。

兩者之間透過由ServiceConnection和AIDL連結,達到複數程式同時執行的效果。如果執行中的Activity全部畫面被其他Activity取代時,該Activity便被停止,甚至被系統清除。

View等同於J2ME的Displayable,程式人員可以透過View類別與「XML layout」檔將UI放置在視窗上,Android 1.5的版本可以利用View打造出所謂的Widgets,其實Widget只是View的一種,所以可以使用xml來設計layout,HTC的Android Hero智慧型手機即含有大量的widget。至於ViewGroup是各種layout的基礎抽象類別,ViewGroup之內還可以有ViewGroup。View的構造函數不需要在Activity中調用,但是Displayable的是必須的,在Activity中,要通過findViewById()來從XML中取得View,Android的View類的顯示很大程度上是從XML中讀取的。View與事件息息相關,兩者之間透過Listener結合在一起,每一個View都可以註冊一個event listener,例如:當View要處理使用者觸碰的事件時,就要向Android框架註冊View.OnClickListener。另外還有Image等同於J2ME的BitMap。

前端檢查檔案上傳是否有達規定

參考:http://itgroup.blueshop.com.tw/topcat/aspx?n=convew&i=5684
 
 
 
上傳 
 
 
圖片:

2012年7月12日 星期四

plugin: Password Validation

Current version: 1.0.0
License: MIT/GPL

Required
  • jQuery 1.2.6+, compatible with 1.3.2
  • jQuery Validation Plugin 1.5+


WEB

plugin Validation

Current version: 1.9.0
Minified filesize (even less with GZip): 21,601 bytes
License: MIT/GPL
WEB:http://bassistance.de/jquery-plugins/jquery-plugin-validation/
DEMO


jquery 官方

http://docs.jquery.com/Plugins/Validation#List_of_built-in_Validation_methods


另一個比較常用的 驗證程式。

<link href="xx/script/form_validator/css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
<link href="xx/script/form_validator/css/template.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="xx/script/form_validator/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="xx/script/form_validator/js/jquery.validationEngine.js"></script>

<script>
$(document).ready(function(){
$("#upp").validationEngine();

})

</script>
<form id='upp'>
<input type='text' class="validate[required,custom[email]] text-input ">
</form>


功能DEMO

原網站.最新版本v2.6.1(2013.04.18更改)

2012年7月10日 星期二

css 下拉式水平選單教學

http://www.minwt.com/css/831.html
預覽


Style a Select Box Using Only CSS

http://bavotasan.com/2011/style-select-box-using-only-css/
預覽

2012年7月9日 星期一

mysql 三個table相串連

select a.id,a.name as a_name,b.name as b_name,c.name
from project a left join customer b on a.customer_id = b.id

left join sales c on a.customer_id = c.id

2012年7月8日 星期日

圖片在ie上顯示不出來

發現客戶在張圖片上傳後,在ie上成了叉燒包,但在chrome和firfox皆可以看到。

搜尋了一下,原來是CMYK的問題。把圖改成RGB就可以了。


以下為找到的解法
http://blog.mukispace.com/solve-ie-no-pic/

2012年6月23日 星期六

1.驗證email 2.驗證是否有值


javascript 驗證email

function validate(form_id,email) {

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;
if(reg.test(address) == false) {

alert('Invalid Email Address');
return false;
}
}

2.驗證是否有值

if(typeOf(x)=='undefined'){
alert('undefined');
}else if(typeOf(x)=='null'){
alert('null');
}

2012年6月21日 星期四

西元轉民國 及 MS-DOS 版本編號

function DtoCh($dday, $st) {
//把西元日期改為民日期 $st為分隔符號
$tok= strtok($dday,$st);
$i  = 0;

while ($tok){
$d[$i]  =$tok;
$tok  = strtok($st) ;
$i   = $i+1 ;
}
$temp=strtok($d[2],' ');
$d[2]=$temp[0].$temp[1];

$d[0] = $d[0] - 1911 ;
$cday = $d[0]."/".$d[1]."/".$d[2] ;
return $cday ;
}
例子:
DtoCh("2011-12-08 15:54:27",'-') ==> 100/12/08

MS-DOS 版本編號:
Windows 98 (Windows 4.1), Windows 98 Second Edition
Windows Millennium Edition (Windows 4.9)

Windows NT 4.0
Windows 2000 (Windows NT 5.0)
Windows XP (Windows NT 5.1)
Windows Server 2003 (Windows NT 5.2)
Windows Vista (Windows NT 6.0)
Windows Server 2008 (Windows NT 6.0)
Windows 7 (Windows NT 6.1)
Windows Server 2008 R2 (Windows NT 6.1)
Windows Home Server
Windows 8 (Windows NT 6.2)

2012年6月19日 星期二

文字 靠左 置中 靠右

靠左
text-align:left;
置中
text-align:center;
靠右
text-align:right;

2012年6月18日 星期一

取整函数ceil floor round intval

ceil —進一取整數

float ceil ( float $value )
取回不小於 value 的下一個整数,value 如果有小數部分則進一位。
echo ceil(4.3); // 5
echo ceil(9.999); // 10

floor — 捨去法取整數

说明
float floor ( float $value )
返回不大于 value 的下一个整数,将 value 的小数部分舍去取整。

echo floor(4.3); // 4
echo floor(9.999); // 9

round — 对浮点数进行四舍五入

说明
float round ( float $val [, int $precision ] )
返回將 val 根据指定精度 precision(十进制小数点后数字的数目)进行四舍五入的结果
。precision 也可以是负数或零(默认值)。

echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06

intval —獲取整数值

说明
int intval ( mixed $var [, int $base ] )
通过使用特定的进制转换(默认是十进制),返回变量 var 的 integer 数值。
var 可以是任何标量类型。intval() 不能用于 array 或 object。
intval() 例子
echo intval(4.3); // 4
echo intval(9.999); // 9

2012年6月8日 星期五

jquery 垂直 menu


垂直演示:http://blog.moocss.com/jQuery/demo15/accordion-menu/index.html

2012年6月6日 星期三

文字處理

文字處理:

strpos

--- 找出字串第一次出現的位置
語法 : int strpos (string haystack, string needle [, int offset])

substr



substr --- 取得部份字串

語法 : string substr (string string, int start [, int length])

explode ---將字串依指定的字串或字元separator切開

語法:array explode(string separator, string string,[int limit])

將字串 "宅配通:123456789" 套用explode,條件":"
$a=explode(':',"宅配通:123456789");
$a[0]='宅配通',$a[1]='123456789'

CODE:

例子:
$ac=exam_560
$pos= strpos($ac,'_');
$id =substr($ac,0,$pos);
$exam_name= substr($ac,$pos+1);
針對字串第一個字是否為大寫!!ex:身分證 Q123584123

CODE:

$b=substr($a,0,1);取得第一個字

//研判第一個字元是不是在A(ASCII值是65)到Z(95)之間,若是,那第一個字母就是大寫字元。
if ( ord($b) >= 65 AND ord($b) <= 95 ) {
echo  "驗證合格!";
}  else {
echo  "第一個字元不是大寫字母!";
} 
補充:ord a: 97 z:127 A: 65 Z: 95

str_replace

mixed str_Replace(mixed search, mixed replace,mixed subject , int &count)
$str=str_replace("mrsoft","吉林省明日科技有限公司","Welcome to mrsoft!");

結果:Welcome to 吉林省明日科技有限公司

例子:將雙引號取代成 code

str_replace('\"', "&quot;",$content);

取得目前頁面的檔案名稱

echo basename(__FILE__);

取得網址(URL中的檔案含副檔名)

例如網址是:http://127.0.0.1/myTest/MyHttp.php
則要利用什麼方法,可以擷取出此文字:MyHttp.php

參考解:
$arr = explode('/',$_SERVER['PHP_SELF']);
$filename = $arr[count($arr)-1];

#當前運行腳本所在的文檔根目錄。在服務器配置文件中定義。

$_SERVER['DOCUMENT_ROOT'];

去掉最後一個逗號/去尾巴

substr($str,0,strrpos($str,','))

亂數

$a=rand(最小值[整數],最大值[整數])

在CKEDITOR 中丟入從word復製的文字或表格,有太多的不必要的word的字元,我想要把那些字完踢掉:
找到一個東西叫preg_replace() 正規表示式取代字串
微軟字元都藏在 span 中,所以把 span全部抓掉

摘錄其中我用的一些功能,詳細功能,請上網找。

$body = preg_replace("/\/",'',$publications2); 
濾掉 

2012年6月4日 星期一

md5 加密 應用在會員密碼

系統管理工程人員 或者 掛載的公司的員工可以輕鬆看到用戶密碼,所以先將用戶密碼加密是必要。
PHP 內建了 MD5() 單向加密演算法,即只可加密,而不可以反向解密,但可以用猜的,只是難度很高。


比對資料

md5($password) 存到資料庫

$sql = mysql_query("select * from users where `username`='$username' and `password`='".md5($password)."'"); 


md5 在class login 中會有錯誤。所以不能放。

2012年5月17日 星期四

常用顏色


http://www.csie.nctu.edu.tw/~jglee/teacher/color.htm

背景:
background-color : #ffffff             //背景色彩
background-image :  url(bg.jpg)        //背景圖片
background-repeat : repeat-x           //水平並排
background-repeat : repeat-y           //垂直並排
background-attachment : fixed          //固定背景
background-repeat : no-repeat          //單張固定
background-repeat : repeat             //重複排列
background-position : 50% 50%          //背景圖與X、Y軸距離


原色大辭典 http://www.colordic.org/

font運用:
h4 { color: red; }
h5 { color: #9000A1; } 
h6 { color: rgb(0, 220, 98); }

h4 { font-family: sans-serif; }
h5 { font-family: serif; }
h6 { font-family: arial; }

p { font-size: 120%; } 
ol{ font-size: 10px; } 
ul{ font-size: x-large; }

p { font-style: italic; }
h4{ font-style: oblique; }

p { font-weight: 100; } 
ul{ font-weight: bolder; }

刪除[彈跳alert詢問是否刪除]

使用javascript 遞送資料
javascript:
function commButtonDel(item,sn){
     var ans=confirm('確定刪除'+item+'?');
     var path='';
    if(ans){   
      location.href=path;
    }
}
html:
<input onclick="commButtonDel('變數1','變數2')" type="button" value="刪除" />



刪除,跳出

2012年5月14日 星期一

html table td colspan、rowspan

ROWSPAN 及 COLSPAN 屬性主要適用於合併儲存格,
ROWSPAN適用於向下延伸合併垂直儲存格(列),
COLSPAN適用於向右延伸合併水平儲存格(行)。
1234
1、23、4
12
1234
1、23、4
12

Cell 1 Cell 2
Cell 3

Cell 1 Cell 2
Cell 3

2012年5月8日 星期二

8個簡單和實用的CSS技巧

  1. 使用line-height來達到垂直居中
    line-height:24px; 當你有一個固定高度的區域,你可以通過把line-height和區域的高度設為相同的數值而達到垂直置中。
  2. 使用overflow防止内容溢出 #main{ overflow:hidden; } 這個應該基本都知道了。可以在限制內容塊的寬度的前提下,隱藏那些有可能溢出的文本或圖像。雖然會導致一些內容被隱藏,但總比溢出撐開影響頁面佈局要好。
  3. 強制在同一行內顯示所有內文 a{ white-space:nowrap;} 強制在同一行內顯示所有內文,直到內文結束或者< br>。
  4. 始終顯示Firefox垂直捲軸 html{ overflow:-moz-scrollbars-vertical;} Firefox默認是不顯示垂直捲軸的,而這個參數設置將能讓它始終顯示垂直捲軸。
  5. 内容置中 margin:0 auto; 這個大家都應該知道了,但是這個設置並不是在所有流覽中都有效。並且,在相同的流覽器中,如果受其他影響,也很可能會失去效果。
  6. 移除IE的默認捲軸 textarea{ overflow:auto;} IE默認是顯示內文框的垂直捲軸,這個參數將移除這個捲軸,除非輸入的內容超過內文框的高度。
  7. 強制列印時自動分頁 h2{ page-break-before:always;} 這個屬性參數可以「始終在物件之前插入頁分割符」,主要用於需要列印的頁面設置。
  8. 移除點擊鏈結時的虛線框 a:active, a:focus{ outline:none;} 大家都知道,點擊鏈結時,通常會出現虛線框,影響美觀。這個屬性設置可以移除點擊時的虛線框。

posted by Jackson

轉貼自:http://takeasy-takeasy.blogspot.com

onload

跳出視窗

<body onLoad="init();">
<div id="content">
It is a book !</div>
</body> 

2012年3月28日 星期三

dos 指令

復製資料夾
dir /w >list.txt

參考網址:
http://pcuser.pixnet.net/blog/post/22391175-%E5%8F%AF%E8%83%BD%E5%BF%AB%E9%80%9F%E8%A4%87%E8%A3%BD%E7%99%BE%E7%B5%84%E5%90%8C%E5%90%8D%E8%B3%87%E6%96%99%E5%A4%BE%E5%88%B0%E5%88%A5%E5%8F%B0%E9%9B%BB%E8%85%A6%E5%97%8E%EF%BC%9F

2012年3月27日 星期二

.htacess

Order Allow,Deny
Deny from all


放在不想被連結的資料夾

2012年2月29日 星期三

Bundle類別

此類別可以保存Activity(活動)上一次關閉(Stop)時的狀態。
可以透過載「onStop」方法(與「onCreate」方法的作用類似)來保存關閉前的狀態。

當程式啟動(Activity重新初始化)時,會再次呼叫「onCreate」方法,我們就能從「SavedInstanceState」中得到次一次凍結的狀態。
我們也可以透過「Bundle」來將這個Activity的內容傳到下一個Activity中

2012年2月22日 星期三

2012年2月21日 星期二

JavaScript 讀取 Cookie 值

讀取cookie的value
Function GetCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}

------------
&&判斷值是否為null

if(value!=null)
  alert('gg');

引用網址

HTML 跳轉頁面 轉頁

進入index.html,不需要點選任何連結就可以自動跳到t_login.php

語法如下
content是秒數(這邊是設定不需要等待就直接跳轉)
url後面是連結網址

index.html的內容:

位置放在 html的head




2012年2月20日 星期一

android 簡單介紹


Android作業系統最初由Andy Rubin創辦,之後被Google併購,目前由Google和硬體製造商及電信運營商組成開放手持設備聯盟開發。

Android以Linux為核心,系統程式包含了 C 語言的標準函式庫,但應用程式主要以Java語言(類似J2ME)在Dalvik VM虛擬機器執行,跨平台(Windows、Mac、Linux)的開發環境齊備,應用程式開發環境以Eclipse為主,加上 Android Development Tools (ADT) Plugin,模擬器(Emulator)、開發工具、SDK等皆可免費下載取得。

google為主要的發佈版本給予一個糕點名稱。
版本:

4.1.x Jelly Bean 雷根糖
16 2012年6月28日

4.0 冰淇淋三明治
14-15 2011年10月19日

3.x.x 蜂巢
11-13 2011年2月2日, 3.0

2.3.x 薑餅
9-10

2.2 凍酸奶
8


2.1 閃電泡芙
7 2009年10月26日,2.0

1.6 甜甜圈
4

1.5 紙杯蛋糕
3

2012年2月19日 星期日

phpExcel


include_once("XXX/phpexcel/PHPExcel/IOFactory.php");
 

 
 $colum=2;
 $num=count($sss);
 $objExcel=new PHPExcel();
 $objExcel->setActiveSheetIndex(0);
 $sheet=$objExcel->getActiveSheet();
  
 for($i=0;$i<$num;$i++){
  //if($data[$i]['enable']==0) continue; #因為sql裡面排除不了enable為0的,所以做此處理
  
  $sheet->setCellValueByColumnAndRow(0,$colum,$sss[$i]['Name']);
  $sheet->setCellValueByColumnAndRow(1,$colum,$sss[$i]['ID']);           
  $sheet->setCellValueByColumnAndRow(2,$colum,$sss[$i]['Time']);
  $sheet->setCellValueByColumnAndRow(3,$colum,$sss[$i]['eTime']); 
  $colum++;
 }

  $path=t_PATH."download/";
  $path="../download/";
//2003
  $objExcel=PHPExcel_IOFactory::createWriter($objExcel,'Excel5'); //針對2003的版本
  $filePath=$path."commodity.xls";     //注意副檔名
// Export to Excel2007 (.xlsx) 匯出成2007
  $objExcel=PHPExcel_IOFactory::createWriter($objExcel,'Excel2007'); //針對2003的版本
  $filePath=$path."commodity.xlsx";    //注意副檔名


  $objExcel->save($filePath);
  
  dl_file($filePath); //此功能應該要和save分開處理,避免產生錯誤

另一個主題:讓phpexcel只讀取column的文字,不會讀取其他的 字體設定,顏色設定。

錯誤碼:Cannot use object of type PHPExcel_RichText

原因:去抓 陣列裡的 PHPExcel_RichText ,要抓出我的的文字而不是字體之類的,就產生了錯誤。
$reader->setReadDataOnly(true);

在20120313時需要寫入大量的資料,遇到疑似記憶體不足,但沒顯示任何錯誤,抓bug抓了老半天,始終抓不到。
解法:放在程式最前面
ini_set( "memory_limit", "56M");


設定欄寬範例 : $sheet->getColumnDimension("A")->setWidth(50); //設定欄冠

2012年2月15日 星期三

javascript 抓取name的內容

情況:
有些許情況下使用document . getElementByname 會抓不到資料。
我在猜有可能是太多form之下,需要指定form才能正確使用。

副程式:


focus( ) method

把注目移到想要的地方。
 
checkbox

  function doOutput()
  {
        var obj=document.getElementsByName("checkbox");
        var len = obj.length;
        var checked = false;

        for (i = 0; i < len; i++)
        {
            if (obj[i].checked == true)
            {
                checked = true;
                break;
            }
        } 
        alert(checked);
  };
form 上傳檔案 加enctype
  

上傳圖片及PHP處理

處理端(接收來自form,並加以處理):
情境:多張圖片上傳


//解晰圖片
$image_type=getimagesize($_FILES['x'.$im]['tmp_name']);

switch ($image_type[2]){
    case "1"://gif
  $src = imagecreatefromgif($_FILES['x'.$im]['tmp_name']);
    break;
    case "2": //jpg
  $src = imagecreatefromjpeg($_FILES['x'.$im]['tmp_name']);
    break;
    case "3":
         $src=imagecreatefrompng($_FILES['x'.$im]['tmp_name']);
    break;
    default:
         echo '
ERROR!!請通知系統人員。
';       
  exit;
 }
壓縮圖檔1:
$file_name   = $_FILES['image'.$im]['name'];
  $src_w   = imagesx($src);
  $src_h   = imagesy($src);
     
  if($src_w > $src_h){
  $thumb_w = 150;
  $thumb_h = intval($src_h / $src_w * 150);
  }else{
  $thumb_h = 110;
  $thumb_w = intval($src_w / $src_h * 110);
  }
壓縮圖檔2:
// 建立縮圖
    $thumb = imagecreatetruecolor($thumb_w, $thumb_h);
    // 開始縮圖
    imagecopyresampled($thumb, $src, 0, 0, 0, 0, $thumb_w, $thumb_h, $src_w, $src_h);
    // 假設要長寬不超過90
    // 複製上傳圖片到指定 images 目錄
  
    $number   = strrpos($file_name,".");
    $orig_name  = substr($file_name,0,$number);
    $sub_file_name  = substr($file_name,$number+1);
    $new_file_name  = time()."_".$num.".".$sub_file_name;
    $dest_filename  = $upload_dir.$new_file_name;
       
    $sql="插入db所需要的資料";
       
    mysql_query($sql);
    $r=mysql_affected_rows();
圖檔儲存在伺服器

if($r>0) {
  switch ($image_type[2]){
     case "1"://gif
   imagegif($thumb, 'path'.$dest_filename);
   copy($_FILES['image'.$im]['tmp_name'], "../images/upload/" .$dest_filename);
     break;
     case "2": //jpg
   imagejpeg($thumb, "path".$dest_filename);
   copy($_FILES['image'.$im]['tmp_name'], "../images/upload/" .$dest_filename);
     break;
     case "3": //png
   imagepng($thumb, "path".$dest_filename);
   copy($_FILES['image'.$im]['tmp_name'], "../images/upload/" .$dest_filename);
     break;
   }
       
    }


form 的元素: enctype='multipart/form-data'
列出上傳的檔案資訊:
print_r($_FILES)
上傳多個標檔案--例子:
科目<input type='file' name='con_subject[]'><br>
                                    科目<input type='file' name='con_subject[]'><br>
                                    科目<input type='file' name='con_subject[]'><br>

接收端 第一個檔案: $_FILES['con_subject']['name'][0]
解釋:
getimagesize
imagecreatefromgif
imagepng

2012年2月8日 星期三

檔案下載

使用的下載方式是跳出下載的方塊而不是瀏覽。
副程式:
//First, see if the file exists
   if (!is_file($file)) { die("404 File not found!"); }

   //Gather relevent info about file
   $len = filesize($file);
   $filename = basename($file);
   $file_extension = strtolower(substr(strrchr($filename,"."),1));
 /*
找了一下檔案下載的程式,在 EcStart 看到這個 Function,用它下載檔案的話,都會以
「下載」的方式呈現,而不是直接在瀏覽器開啟檔案。
http://my-web-design.blogspot.com/2010/08/php.html#links
 */
 
   //This will set the Content-Type to the appropriate setting for the file
   
  switch( $file_extension ) {
     case "pdf": $ctype="application/pdf"; break;
     case "exe": $ctype="application/octet-stream"; break;
     case "zip": $ctype="application/zip"; break;
     case "doc": $ctype="application/msword"; break;
     case "xls": $ctype="application/vnd.ms-excel"; break;
     case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
     case "gif": $ctype="image/gif"; break;
     case "png": $ctype="image/png"; break;
     case "jpeg":
     case "jpg": $ctype="image/jpg"; break;
     case "mp3": $ctype="audio/mpeg"; break;
     case "wav": $ctype="audio/x-wav"; break;
     case "mpeg":
     case "mpg":
     case "mpe": $ctype="video/mpeg"; break;
     case "mov": $ctype="video/quicktime"; break;
     case "avi": $ctype="video/x-msvideo"; break;
     case "txt": $ctype="text/plain"; break;

     //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files)
     case "php":
     case "htm":
     case "html":die("Cannot be used for ". $file_extension ." files!"); break;

     default: $ctype="application/force-download";
   }

   //Begin writing headers
   header("Pragma: public");
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: public");
   header("Content-Description: File Transfer");
  
   //Use the switch-generated Content-Type
   header("Content-Type: $ctype");

   //Force the download
   $header="Content-Disposition: attachment; filename=".$filename.";";
   header($header );
   header("Content-Transfer-Encoding: binary");
   header("Content-Length: ".$len);
   @readfile($file);
   exit;


2012.10.
下載檔名中有中文 產生亂碼,解法:
mb_convert_encoding($chineseFile,"BIG-5","UTF-8"); 
您可能有興趣的書單:
  1. 培養與鍛鍊程式設計的邏輯腦:世界級程式設計大賽的知識、心得與解題分享
  2. Android 4.X手機/平板電腦程式設計入門、應用到精通(第二版--適用Android 1.X~4.X)(附光碟)

2012年2月7日 星期二

PHP陣列

語法:array array(mixed...])

參數mixed的語法為"key=>value",多個參數mixed用逗號分開

如果省略了索引,會自動產生從0開始的整數索引


範例:
$array=array("ASP","PHP","JSP");
$rray[]="ASP",$rray[]="PHP",$rray[]="JSP"
$array3=array("a"=>"books","b"=>"apple","c"=>"orig")


array_search :在陣列中尋找指定的值, 傳回值true/false
語法:mixed array_search(mixed needle,array haystack[,bool strict])

搜尋陣列中是否有8這個數字。
array_search('8',$array);


1.explode():此函式可以將字串分割為陣列儲存,類似切token的方式,若以下列程式碼為例:
$student="kevin susan james";
$stuednt_array=explode(" ",$student);
foreach($stuednt_array as $index => $value)
echo "student $index is: $value\n";

則結果為:
student 0 is: kevin
student 1 is: susan
student 2 is: james

2.implode():此函式可以將陣列合併為字串儲存,若以下列程式碼為例:
$stuednt_array = array(kevin, susan, james);
$student = implode(",", $stuednt_array);
echo $student

把$_POST 的資料用成$key=>$value 的方式,不用在自己轉換成變數,減少很多麻煩。

$_POST = array_map('trim', $_POST);


foreach($_POST as $key => $value) {
${'post_' . $key} = mysql_real_escape_string($value);
}

輸出就是 $post_key的方式丟出來

on duplicate key update (pk key 不存在,新增資料;有重覆值採用更新)

使用此指令需要 MYSQL版本5.0以上。
官網資料:http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
範例:INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
假設unique 為a欄位:
資料 INSERT INTO table (a,b,c) VALUES values(1,2,3) ON DUPLICATE KEY UPDATE c=c+1; 會更新c=c+1
資料 INSERT INTO table (a,b,c) values(2,2,3) ON DUPLICATE KEY UPDATE c=c+1;會新增資料(2,2,3)



2012年2月3日 星期五

date 日期格式化

阿都仔的日期表示方式多以: 日/月/年
英文裡的數,可以分為「基數」(one、two、three)與「序數」(第一first、第二second、第三third)
日期表示:
  • 1號、11號、21號、31號  英文 => 1st, 11st, 21st, 31st (數字後面加 st)
  • 2號、12號、22號 英文 = 2nd, 12nd, 22nd (數字後面加 nd)
  • 3號、13號、23號 英文 = 3rd, 13rd, 23rd (數字後面加 rd )
  • 其他的後面(4~9)加 "th" 就符合規則了如=> 19th, 24th, 8th



MYSQL
取得現在時間---------------
select DATE_FORMAT(NOW(),'%H:%s, %D %b., %Y')==> 09:01, 2nd Feb., 2012

符合 rfc822
$date=gmdate("D, d M Y H:i:s", $this->unix);
DATE_FORMAT(time,'%a, %d %b %y %k:%i:%s +0000')

PHP
取得現在時間---------------
echo date("Y/m/d H:i",time()); //其結果為2010/03/24 14:32
echo date("H:i,jS D.,Y"); //結果:11:38,6th Mon.,2012

PHP:
d - 幾日,兩位數字,若不足二位則前面補零; 如: "01" 至 "31"
j - 幾日,兩位數字,若不足二位不補零; 如: "1" 至 "31"
D - 星期幾,三個英文字母; 如: "Fri"
l - 星期幾,英文全名; 如: "Friday"
F - 月份,英文全名; 如: "January"
Y - 年份,四位數字; 如: "1999"
y - 年份,二位數字; 如: "99"
h - 12 時制的小時; 如: "01" 至 "12"
H - 24 時制的小時; 如: "00" 至 "23"
g - 12 時制的小時,不足二位不補零; 如: "1" 至 12"
G - 24 時制的小時,不足二位不補零; 如: "0" 至 "23"
i - 分鐘; 如: "00" 至 "59"
m - 月份,兩位數字,若不足二位則在前面補零; 如: "01" 至 "12"
n - 月份,兩位數字,若不足二位則不補零; 如: "1" 至 "12"
M - 月份,三個英文字母; 如: "Jan"
s - 秒數; 如: "00" 至 "59"
S - 字尾加英文序數,二個英文字母; 如: "th","nd"
t - 指定月份的天數; 如: "28" 至 "31"
U - 總秒數
w - 數字型的星期幾,如: "0" (星期日) 至 "6" (星期六)
z - 一年中的第幾天; 如: "0" 至 "365"

date('U',time())


主要是將文字日期改為Unix時間戳記

$ThisDay = '2008-01-01';
$ThisDay = strtotime($ThisDay); // 將日期轉為Unix時間戳記
echo date("Y-m-d",strtotime("now",$ThisDay)). "\n";
//顯示2008-01-01
echo date("Y-m-d",strtotime("+1 day",$ThisDay)). "\n";
//顯示2008-01-02
echo date("Y-m-d",strtotime("+1 week",$ThisDay)). "\n";
//顯示2008-01-08
echo date("Y-m-d",strtotime("+1 week 2 days 4 hours 2 seconds",$ThisDay)). "\n";
//顯示2008-01-10
echo date("Y-m-d",strtotime("next Thursday",$ThisDay)). "\n";
//顯示2008-01-03
echo date("Y-m-d",strtotime("last Monday",$ThisDay)). "\n";
//顯示2007-12-31
以上範例會有1970的問題
使用 date_default_timezone_set('UTC'); 可以解決
日期:2012-01-13 00:56:35
date("Y-m-d 00:00:00",strtotime("-1 week"))  //往前推七天 2012-01-06 00:00:00 


date('U',time()); 獲得現在的秒數

mktime(hour,minute,second,month,day,year,is_dst)
範例:今天往後算一個月的日子
$years  = date("Y");     
$months = date("m");     
$days  = date("d");     
$day  = date("Y-m-d",mktime(0,0,0,$months+1,$days,$years));

只有 小時與分鐘,所以mysql 的 unix_timestamp 不能用。

找出 開始與結束時間是否是一樣的

$ss_start=($_sHour * 60 + $_sMinute)*60; //秒
$ss_end=($_eHour * 60 + $_eMinute)*60; //秒

$sql="select * from `XXX` where TIME_TO_SEC( `start`)='$ss_start' and TIME_TO_SEC(`end`)='$ss_end' and auto='{$auto_id}'";

2012年2月1日 星期三

change(下拉式選單)



圖示:

2012年1月30日 星期一

JavaScript Date Time Picker

網址
download
更改datetimepicker_css.js(版本Version: 2.2.2)
var StartYear =2010;         //可以指定起始的年度
var imageFilesPath = "xxx";  //指定圖片路徑

2012年1月19日 星期四

定位、間距與內襯

■position:
定位規則有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 屬性來描述,而不必四個邊都描述一次。另外,我們可以在同一行一次宣告邊框樣式、邊框寬度、以及邊框顏色。

CSS width height 屬性

width: 这個属性定義元素内容區的宽度,在内容区外面可以增加内邊距、邊框和外邊距。
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
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

2012年1月17日 星期二

jQuery Scroll to Top Control v1.1

網址http://www.dynamicdrive.com/dynamicindex3/scrolltop.htm
引用檔: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

jquery 衝突

因為引用多個jquery的關係,有機會引起jquery的互相衝突。
解決方式:
將其中的jquery 自訂一個捷徑:
var $j=jQuery.noConfilict();
  $j(function(){
     })

鋒利的jQuery第1-20頁有提到。

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。
// 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日 星期一

CSS Sprites 減少對伺服器的圖片需求

有效減少對伺服器的請求。
製作網址:
http://spritegen.website-performance.org/
參考寫法:
http://demo.tc/Post/477
下圖上傳三張圖片後(合併成一張大圖,大圖要丟到FTP喔),系統給你的指示:
在用紅色圈起來的地方,因為看不懂,所以我就只好參考一下別人的寫法囉:
下面是我寫的語法:

 
水族館

Jquery 的show 及hide

ID:check 為checkBox ID: cCArea 為顯示的AREA
利用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
$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

相關詞:返回連結
<input type='button' onclick='javascript:window.history.back()' value='哈哈' />




到某個網址:
EX:
self.location='目標網址';

Q:我使用回到上一頁的javascript:window.history. back() 會出現 上一頁 網頁已過期的訊息~"~
ans:只要使用過form post 的環境下,回到上一頁會有出現已過期的訊息。
只要用"到某個網址"的方過就可以解決這個問題。

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/

2012年1月6日 星期五

jQuery選擇器

Attribute Filters (屬性過慮器)

[attribute]
用法: $(“div[id]“) ;

[attribute^=value]
用法: $(“input[name^='news']“) ;

2012年1月5日 星期四

UI Datepicker

demo:http://jqueryui.com/demos/datepicker/





<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")
}


彈跳視窗、關閉視窗

引入檔案:








場景:表格下每列的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();}

tablesorter

網址:http://tablesorter.com/docs/example-pager.html

$(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資料

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 API的問題

facebook XXX人說這讚。成為你朋友中第一個說這讚的人。



底下的YOUR_URL 放入您facebook的網址:



2012年1月2日 星期一

HTML 5 對於 table的支援度



沒支援的,請用CSS補足
1.border不填寫 有html4的border=0的效果
2.css>消除圖片的藍邊框 解法 img{border:0px;}

cellpadding:指定儲存格內容和儲存格邊框之間的間距。
cellspacing:指定儲存格之間的間距

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


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';

HTML5 起始1

進入HTML 5的年代,對於前端開發人員,著實是一大福因,因為HTML 5 致力於解決跨瀏覽器問題,也可以部份取代原來的JavaScript。
借助於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:建置與執行

HTML5 驗證器

http://html5.validator.nu

stripslashes 去除多餘的斜線

問題:使用ckeditor新增圖片,在丟出資料庫裡的資料時,發現會有多的斜線。
解法:用stripslashes函數







套上後:


不過ckeditor 與jquery UI之間的問題還是無法解決

Yahoo Login API

可以用下列三種認證/授權方式,

1. OAuth

2. OpenID

3. BBAuth

Using Yahoo! Social SDK for PHP