<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="http://120.112.17.17/blog/styles/rss.css" type="text/css"?>
<rss version="0.91">

 <channel>
  <title>豬窩</title>
  <link>http://120.112.17.17/blog/shyong</link>
  <description> 小豬的備忘錄,對錯完全不負責 
</description>
    <item>
   <title>php 驗證碼 imgage 圖像函數,font 路徑</title>
   <description> 
在驗證碼使用 imaettftext 時,  imagettftext ( resource 
image, float size, float angle, int x, int y, int color, string 
fontfile, string text ),fontfile 可能因為 
GD版本不同,查找目錄的方式可能不同,因此找不到字型檔,在檔案前加入路徑,如:$font = './symbol.ttf';加入 ./ 
強迫查找當前目錄就可以
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/599</link>
      <pubDate>Sun, 20 Jun 2021 12:42:27 +0800</pubDate>   
  </item>
    <item>
   <title>驗證碼重新讀取</title>
   <description> 
今天在玩網頁登入加入驗證碼,可是在重新讀取時一直沒有作用,後來查網才知道,因為 src 沒有改變,所以不會重新執行
 
原來 img 的 jquery
 
$(&quot;#getcode_num&quot;).click(function(){ 
&nbsp;&nbsp; &nbsp;$(this).prop(&quot;src&quot;, &quot;captcha/code_num.php&quot; ); }) &nbsp;
 
//沒有作用,因為 src =&nbsp; &quot;captcha/code_num.php&quot; 永遠一樣.,不會改變
 
改成
 
$(&quot;#getcode_num&quot;).click(function(){ 
&nbsp;&nbsp; &nbsp;$(this).prop(&quot;src&quot;, &quot;captcha/code_num.php?code=&quot; + Math.random());&nbsp;&nbsp; });&nbsp;&nbsp;
 
//改變,因為 src = &quot;captcha/code_num.php?code=&quot; + Math.random()); 因為 random每次改不一樣的值,code 參數隻是讓 src 不一樣,在後端不用處理
 
 
&nbsp;
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/597</link>
      <pubDate>Sun, 08 Nov 2020 21:41:16 +0800</pubDate>   
  </item>
    <item>
   <title>php mysqli_multi_query 執行多筆 sql 指令 -- update 多筆用</title>
   <description> 
在 update 不同值時, mysqli_query 只能一筆一筆更新,時間效率都很差,上網找的方法是產生一個更新資料暫存表,再用唯一值一次更新.
 
 
經過重覆測試,指令如下:&nbsp; 
 
 

 
 
$sql1 = &quot;CREATE TABLE IF NOT EXISTS `std_pnum` (&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  //產生暫存,最後沒有刪除,想說都要用  
&nbsp; `stdno` varchar(10) NOT NULL, 
&nbsp; `subjno` text NOT NULL, 
&nbsp; `class` varchar(6) DEFAULT NULL, 
&nbsp; `grade` varchar(8) DEFAULT NULL, 
&nbsp; `seme` varchar(6) DEFAULT NULL, 
&nbsp; `pnum` smallint(6) DEFAULT NULL 
) ENGINE=InnoDB DEFAULT CHARSET=utf8;&quot;; 
 
 
$sql1 .= &quot;delete from std_pnum ;&quot;;&nbsp;&nbsp;&nbsp;  //一開始先清空 tmp表   
$sql1 .= &quot;set @count := $bnum ; &quot;;&nbsp;  //設定開始更新值,由 php 代入 
,宣告變數要用 set 或 select ,不可用 declare (在有 begin - end 內才可以用,一開始用 Declare 在這裡卡好久)&nbsp; 
 
 
 //用現有資料,利用 stdno 當唯一值,相同同編號,因為 @count := @count + 1 會跟來源變動,所以用子查詢我方式,將來源先轉成單純的唯一值排序,這樣@count 才會正常累加 
 
 
&nbsp;&nbsp;&nbsp; $sql2 = &quot;insert into std_pnum  
&nbsp;&nbsp; &nbsp;select c.stdno,c.subjno,c.class,c.grade,c.seme, @count := @count + 1 from  
&nbsp;&nbsp; &nbsp;(select a.* from pig_reopen_std a LEFT JOIN student b ON a.stdno = b.stdno  
&nbsp;&nbsp; &nbsp;WHERE a.indate &gt;= '{$config['okdate']}' AND 
a.syear={$config['syear']} AND ((a.delete_yn&lt;&gt;'Y') Or (a.delete_yn
Is Null)) AND a.pnum &lt;= 0  
&nbsp;&nbsp; &nbsp;group by a.stdno  
&nbsp;&nbsp; &nbsp;ORDER BY b.classno,b.seat,a.stdno,a.subjno,a.class,a.grade,a.seme) c ; &quot;;&nbsp;&nbsp;&nbsp; 
 
 
 //直接用產生的暫存表更新  
&nbsp;&nbsp; &nbsp;$sql3 = &quot;update pig_reopen_std a ,std_pnum b set a.pnum=b.pnum where a.stdno = b.stdno ;&quot;; 
&nbsp;&nbsp; &nbsp;$sql = $sql1 . $sql2 . $sql3 ; 
 
 
&nbsp;&nbsp; if (mysqli_multi_query($link, $sql)) {&nbsp;&nbsp;&nbsp;  //執行sql   
&nbsp;&nbsp; do { 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mysqli_free_result($result); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mysqli_more_results($link)) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$up_num = mysqli_affected_rows ( $link );&nbsp;  //取得最後更新筆數  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } 
&nbsp;&nbsp;&nbsp; } while (mysqli_next_result($link)); 
&nbsp;&nbsp;&nbsp;}
 
&nbsp;&nbsp; &nbsp;
 
 
本來更新350筆要14秒,現在馬上完成,顯示0秒 
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/596</link>
      <pubDate>Thu, 10 Sep 2020 21:14:44 +0800</pubDate>   
  </item>
    <item>
   <title>mysql 插入數據時出現 Incorrect string value: &#039;\xF0\x9F...&#039; for column &#039;name&#039; at row 1的異常</title>
   <description> 
最近在用 Excel 檔匯入資料時,顯示 Error , 轉成 Csv 再匯入就正常, 查網,原來是有些 Utf8 圖型或造字用到 
4碼(含)以上,而 Mysql 的 Utf8 內定3碼,解決方法網上是將內定 Utf8 3碼改成 
character-set-server=utf8mb4 
4碼,資料表也要更改(https://blog.csdn.net/m0_37983376/article/details/79224862)有修改方法,可是我改後無效,不知少了什麼,後來想,那些造字沒有顯示對網頁來說沒有那麼重要,所以想到一個取巧的方式,將這些字丟掉不存在就可以了,方法是,在
php 程式,將 utf8 轉成 big5 ,那些字就會用 &quot;?&quot; 代替,再將它轉回 Utf8 給網頁用,再樣那些字就給轉不見了, Csv 
不用轉,因為它本來就是 big5,程式自動轉成 Utf8 ,指令如下:
 
 
if($type != &quot;csv&quot;)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //不是csv檔,$str 轉big5再轉回Utf-8,排除 utf8 4碼以上字及造字,mysql utf8 內定三碼&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str5 = mb_convert_encoding($str, &quot;big5&quot; , &quot;UTF-8&quot;); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str = mb_convert_encoding($str5, &quot;UTF-8&quot;, &quot;big5&quot;); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } 
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/594</link>
      <pubDate>Wed, 12 Aug 2020 17:31:35 +0800</pubDate>   
  </item>
    <item>
   <title>phpexcel中PHPExcel_Exception Invalid cell coordinate</title>
   <description> 
那是欄位超出 26 的原因,Excel A1.B1.......Z1,AA1,AB1...所以輸出的時侯要轉換, Google 
看到直接在程式轉換,覺的不好用,自己寫一個小函數,代入 row 從 0 開始,直接轉換 
A,B,C.....AA,AB,AC........ZX,ZY,ZZ ,應該足夠用
 
 
function n2a($num) 
{ 
&nbsp;&nbsp;&nbsp; $b = 26;&nbsp;&nbsp;&nbsp; //除數,26個英文字母 
&nbsp;&nbsp;&nbsp; $c = 64;&nbsp;&nbsp;&nbsp; //商+64 ,第二位英文字 
&nbsp;&nbsp;&nbsp; $d = 65;&nbsp;&nbsp;&nbsp; //餘數+ 65 , 餘數字母 
&nbsp;&nbsp;&nbsp; $aa =(int)($num / $b) ;&nbsp; //有無超過 26 
&nbsp;&nbsp;&nbsp; $bb = $num % $b ;&nbsp; //餘數 
&nbsp;&nbsp;&nbsp; $ret = ($aa) ? chr($aa+$c).chr($bb+$d) : chr($bb+$d) ;&nbsp;&nbsp;&nbsp;&nbsp;
 
 
&nbsp;&nbsp;&nbsp; return $ret; 
} 
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/592</link>
      <pubDate>Wed, 22 Jul 2020 22:55:14 +0800</pubDate>   
  </item>
    <item>
   <title>javascript 不同型態比較不相等</title>
   <description> 
在取部份字串時, 用 substr 取是 String&nbsp; ,match 取是 Object ,直接 if(substr == match) 傳回 False 必須改字串才能比較,如下:
 
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var str = 'c002'; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mstr = str.match(/\d+/). toString() ; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sstr = str.substr( 1 , 3 ). toString() ; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; alert(mstr + &quot; = &quot; + typeof(mstr) + &quot;\n&quot; + sstr + &quot; = &quot; + typeof(sstr)); 
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/591</link>
      <pubDate>Tue, 07 Jul 2020 20:46:41 +0800</pubDate>   
  </item>
    <item>
   <title>jquery 用 display 時 ie 沒有作用</title>
   <description>jquery 在用 select option 時 hide() 在 firefox , chrome 可以,但是在 ie 時沒有作用,只能用 disabled ,後來想到 jquery 可以串聯使用,於是試用 $(&quot;.arrnoout&quot;).prop('disabled',true).hide(); 將兩種功能串在一起,各取所需儘然可以, firefox,chrome 可以 hide(), 而 ie 也可以 disabled</description>
   <link>http://120.112.17.17/blog/shyong/archives/590</link>
      <pubDate>Sun, 21 Jun 2020 18:38:53 +0800</pubDate>   
  </item>
    <item>
   <title>用 jquery 時更改 js 檔一直沒用</title>
   <description>今天在改程式時,增加網頁功能,更改 jquery 的 js 檔案,一直沒有作用,後來想到是不是 buffer 問題,直接叫出我的 js 檔 (piggy.js) 結果沒有更改,重新整理後改成新的就有作用了,第一次碰到,原來 js 檔可能在 buffer ,而不會更新,下次碰到要記得叫出來看看</description>
   <link>http://120.112.17.17/blog/shyong/archives/589</link>
      <pubDate>Sat, 20 Jun 2020 10:47:26 +0800</pubDate>   
  </item>
    <item>
   <title>jqurey  及 form table  的順序</title>
   <description> 
今天在用 Ajax 的查圖程序時,當更改圖檔時在 pc,ipad 手機時,圖檔顯示都正常,可是在 andrid 手機時會最大化到超出螢幕 , 後來發現只要將  順序改為&lt;form...&gt;&lt;table ...&gt; 
就正常了,之前在新增 html 檔案時也發現過一次,看來用 &lt;form...&gt; &lt;table...&gt; 時比較不會出狀況的,至於為什麼,不知道 
 
 
20200914
 
 
只要是用新増 html 元件的都要用&nbsp;  &lt;form&gt;&lt;table&gt;  ,用 &lt;table&gt;&lt;form&gt;在 client 有作用,但是在 Server端,抓不到新增元件的值 
 
 
&nbsp;
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/581</link>
      <pubDate>Sun, 18 Nov 2018 20:13:58 +0800</pubDate>   
  </item>
    <item>
   <title>alter table Sql 表格處理</title>
   <description> 
第一，我們要加入一個叫做 &quot;Gender&quot; 的欄位。這可以用以下的指令達成：
 
 
  ALTER TABLE Customer ADD Gender char(1);  
 
 
 
接下來，我們要把 &quot;Address&quot; 欄位改名為 &quot;Addr&quot;。這可以用以下的指令達成：
 
 
  ALTER TABLE Customer CHANGE Address Addr char(50);  
 
 
 
再來，我們要將 &quot;Addr&quot; 欄位的資料種類改為 char(30)。這可以用以下的指令達成：
 
 
  ALTER TABLE Customer MODIFY Addr char(30);  
 
 
 
最後，我們要刪除 &quot;Gender&quot; 欄位。這可以用以下的指令達成：
 
 
  ALTER TABLE Customer DROP Gender;  
 
 
&nbsp;
 
 
來自:https://www.1keydata.com/tw/sql/sql-alter-table.html  
 
&nbsp;
 
&nbsp;
 
&nbsp;
 </description>
   <link>http://120.112.17.17/blog/shyong/archives/578</link>
      <pubDate>Sun, 14 Oct 2018 17:42:36 +0800</pubDate>   
  </item>
   </channel>
</rss>

