發表文章

[PHP] CI 分頁 第一頁的URL

http://stackoverflow.com/questions/9989494/first-page-link-issue-in-codeigniter-pagination-library $config [ 'first_url' ] = 'method/page/1' ; $this -> pagination -> initialize ( $config );

jQuery 取得表單資料、單選 Radio 與多選 Checkbox 的方法/判斷 checkbox 是否選取,實現全選跟全部取消

全部選取/取消選取 checkbox $('#check-all').bind('click',function(){ var data_check = $(this).attr('data-check'); if(data_check === "0"){ $('input[name="place_ids[]"]').prop('checked',true); $('input[name="place_ids[]"]').parent().addClass('checked'); $(this).attr('data-check',1); $(this).html('取消全選'); }else{ $('input[name="place_ids[]"]').prop('checked',false); $('input[name="place_ids[]"]').parent().removeClass('checked'); $(this).attr('data-check',0); $(this).html('全部選取'); } }); 轉自  http://blog.miniasp.com/post/2011/04/27/jQuery-get-form-value-Checkbox-Radio.aspx var cbxVehicle = new Array(); $( 'input :checkbox :checked[name="vehicle"]' ).each( function (i) { cbxVehicle[i] = this .value; }); 另一個寫法是透過  .map()  將回傳值轉譯成為另一種陣列,如下: $( 'input :checkbo...

[linux] 將大量.gif副檔名改成.jpg

for file in *.gif; do mv "$file" "`basename $file .gif`.jpg" done

[PHP] 用程式將jpg丟給瀏覽器,Send jpg to browser ; 用CI將圖片縮圖後傳送到瀏覽器

/////////////////程式將jpg丟給瀏覽器開始///////////////// $img_path = '/var/www/html/XXX//img/a.jpg'; //成功後吐出圖片回傳 $type = 'image/jpeg'; header('Content-Type:'.$type); header('Content-Length: ' . filesize($img_path)); readfile($img_path); /////////////////程式將jpg丟給瀏覽器結束///////////////// /////////////////程式將jpg丟給瀏覽器開始///////////////// /*load library*/ $this->load->library('image_lib'); $this->load->library('net_util'); //必須在linux上安裝gd2 $this->img['image_library'] = 'gd2'; $this->img['maintain_ratio'] = TRUE; //縮圖使用 private function img_resize($source,$target,$width,$height,$crop=true,$img_name,$new_foler){ list($w,$h)=getimagesize($source); if ($w/$width>$h/$height){ $this->img['width'] = $w*($height/$h); $this->img['height'] = $height; $this->img['x_axis'] = ($this->img['width']-$width)/2; $this->img['y_axis'] = 0; }else{ $this->im...

MySQL筆記 IFNULL ,CASE WHEN

case when reference: http://jax-work-archive.blogspot.tw/2008/06/case-mysql-switch-if-else.html 必須在 SELECT,UPDATE,INSERT,DELETE 中 具有 switch 與 if else 兩種方式可用 #switch 的用法 SELECT CASE a WHEN 100 THEN a WHEN 50 THEN '0' ELSE '3' END FROM table; #if else 的用法 SELECT CASE WHEN a>100 THEN a WHEN a>50 THEN '0' ELSE '3' END FROM table; IFNULL reference: http://www.barryblogs.com/mysql-ifnull-if/ SELECT IFNULL(0, 1) ->0!=null,所以回傳0 SELECT IFNULL(1, 10) => 1!=null,所以回傳1 SELECT IFNULL(NULL, 'YES') =>若第一個參數為null時,回傳第二個參數,回傳YES

[Ubuntu] 不負責任之phpmyadmin出現#1146 - Table 'phpmyadmin.pma_recent' doesn't exist錯誤之解法

原文引用 :  http://stackoverflow.com/questions/12760394/1146-table-phpmyadmin-pma-recent-doesnt-exist 懶得看只好快速解,但我不知道原因..沒甚麼時間google只能記錄下來 sudo vi /etc/phpmyadmin/config.inc.php 約在81行處 將所有的pma_ 改成 pma__ (兩個底線)

jQuery - 將function綁定再img上

$(document).ready(function() { // 將element中的img的id有開頭為"img_"的 全部綁上這個function $("img[id^='img_']").bind("click",function(){ // 在其中可直接取得該element的src ch_pic($(this).attr('src')); }); }); Reference : http://design2u.me/blog/943/jquery-notes-g-selector-the-selector