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/