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/
您可能有興趣的書單:
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秒
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; } } }
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);
<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>
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);
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; }
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; } }
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 ; }例子:
$ac=exam_560 $pos= strpos($ac,'_'); $id =substr($ac,0,$pos); $exam_name= substr($ac,$pos+1);針對字串第一個字是否為大寫!!ex:身分證 Q123584123
if ( ord($b) >= 65 AND ord($b) <= 95 ) { echo "驗證合格!"; } else { echo "第一個字元不是大寫字母!"; }補充:ord a: 97 z:127 A: 65 Z: 95
$body = preg_replace("/\/",'',$publications2);
濾掉
md5($password) 存到資料庫 $sql = mysql_query("select * from users where `username`='$username' and `password`='".md5($password)."'");
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/
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; }
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="刪除" />
1 | 2 | 3 | 4 |
1、2 | 3、4 | ||
1 | 2 |
1 | 2 | 3 | 4 |
1、2 | 3、4 | ||
1 | 2 |
Cell 1 | Cell 2 |
Cell 3 |
Cell 1 | Cell 2 |
Cell 3 |
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');
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 |
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的文字,不會讀取其他的 字體設定,顏色設定。
$reader->setReadDataOnly(true);
ini_set( "memory_limit", "56M");
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
//解晰圖片 $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'列出上傳的檔案資訊:
科目<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]
//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;
mb_convert_encoding($chineseFile,"BIG-5","UTF-8");您可能有興趣的書單:
$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
$years = date("Y"); $months = date("m"); $days = date("d"); $day = date("Y-m-d",mktime(0,0,0,$months+1,$days,$years));
var StartYear =2010; //可以指定起始的年度 var imageFilesPath = "xxx"; //指定圖片路徑
直接添加到網頁中。 程序代碼
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。
p.ex1 { font:15px arial,sans-serif; } p.ex2 { font:italic bold 12px/30px Georgia, serif; }
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;
1. 除IE外都可识别 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
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
// 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
//副程式 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 ,從中2選一。 if($("#cch2").attr("checked")){ $("#cck1Area").show("fast"); $("#cck2Area").hide("fast"); }
$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附檔名的檔案檔案之複製、刪除、更名
$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 );
$number = strpos($filename,"."); $file_body = substr($filename,0,$number);
<input type='button' onclick='javascript:window.history.back()' value='哈哈' />
self.location='目標網址';
<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>
<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")
}
................ ........... ...........
$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()'>
<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();}
$(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,優化的話,可以讓上面兩個同步。
BODY:
你的table資料
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
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';
<!DOCTYPE HTML> <html> <head> <title>Title of the document</title> </head> <body> The content of the document...... </body> </html>meta 為utf-8 在 HTML5下可以縮減為:
書單:HTML5:建置與執行