<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>S i X h E a D { ? } &#187; PHP</title>
	<atom:link href="http://sixhead.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://sixhead.com</link>
	<description>เมื่อความรู้มีไว้แบ่งปัน</description>
	<lastBuildDate>Tue, 31 Aug 2010 05:48:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PsychoStats and PHP 5.3</title>
		<link>http://sixhead.com/2010/06/16/psychostats-and-php-5-3-2/</link>
		<comments>http://sixhead.com/2010/06/16/psychostats-and-php-5-3-2/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 03:28:47 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PsychoStats]]></category>

		<guid isPermaLink="false">http://sixhead.com/?p=570</guid>
		<description><![CDATA[Open includes/common.php change line 45 from error_reporting&#40;E_ALL ^ E_NOTICE&#41;; &#160; to error_reporting&#40;E_ERROR&#41;; &#160; Open includes/class_table.php change line 163 from $ret = call_user_func_array&#40;$callback, $params ? array&#40;$html, $params&#41; : $html&#41;; &#160; to $ret = call_user_func_array&#40;$callback, $params ? array&#40;$html, $params&#41; : array&#40;$html&#41;&#41;; &#160;]]></description>
			<content:encoded><![CDATA[<p>Open includes/common.php change line 45<br />
from</p>
<pre class="php"><a href="http://www.php.net/error_reporting"><span style="color: #000066;">error_reporting</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">E_ALL</span> ^ <span style="color: #000000; font-weight: bold;">E_NOTICE</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>to</p>
<pre class="php"><a href="http://www.php.net/error_reporting"><span style="color: #000066;">error_reporting</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">E_ERROR</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p><span id="more-570"></span><br />
Open includes/class_table.php change line 163<br />
from</p>
<pre class="php"><span style="color: #0000ff;">$ret</span> = <a href="http://www.php.net/call_user_func_array"><span style="color: #000066;">call_user_func_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$callback</span>, <span style="color: #0000ff;">$params</span> ? <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$html</span>, <span style="color: #0000ff;">$params</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0000ff;">$html</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>to</p>
<pre class="php"><span style="color: #0000ff;">$ret</span> = <a href="http://www.php.net/call_user_func_array"><span style="color: #000066;">call_user_func_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$callback</span>, <span style="color: #0000ff;">$params</span> ? <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$html</span>, <span style="color: #0000ff;">$params</span><span style="color: #66cc66;">&#41;</span> : <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$html</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p><map name='google_ad_map_570_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/570?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_570_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=570&amp;url= http%3A%2F%2Fsixhead.com%2F2010%2F06%2F16%2Fpsychostats-and-php-5-3-2%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2010/06/16/psychostats-and-php-5-3-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ใช้ mysql_fetch_assoc แทน mysql_fetch_array กันดีกว่า</title>
		<link>http://sixhead.com/2009/06/19/mysql_fetch_assoc-vs-mysql_fetch_array/</link>
		<comments>http://sixhead.com/2009/06/19/mysql_fetch_assoc-vs-mysql_fetch_array/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 04:30:09 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://sixhead.com/?p=444</guid>
		<description><![CDATA[ถ้าเวปคุณเล็กๆ คนเข้าน้อยคงไม่ต้องสนใจรายละเอียดอะไรมากนัก แต่วันนึงเวปเริ่มโต คนเริ่มเยอะ การเปลี่ยนแปลงนิดเดียวอาจได้ผลที่น่าแปลกใจ ปกติส่วนมากเราจะ query แบบนี้ &#60;?php $sql = &#34;SELECT * FROM table&#34;; $result = mysql_query&#40;$sql&#41;; if &#40;!$result&#41; &#123; echo &#34;$sql&#34;; die&#40;&#34;\n Invalid query: &#34; . mysql_error&#40;&#41;&#41;; &#125; while&#40;$row = mysql_fetch_array&#40;$result&#41;&#41; &#123; $ConcertId= $row&#91;&#34;ConcertId&#34;&#93;; $ConcertName= $row&#91;&#34;ConcertName&#34;&#93;; &#125; mysql_free_result&#40;$result&#41;; ?&#62; ถ้าใช้ mysql_fetch_array จะได้ array ($row) ดังนี้ Array ( [0] =&#62; 40 [ConcertId] =&#62; 40 [...]]]></description>
			<content:encoded><![CDATA[<p>ถ้าเวปคุณเล็กๆ คนเข้าน้อยคงไม่ต้องสนใจรายละเอียดอะไรมากนัก แต่วันนึงเวปเริ่มโต คนเริ่มเยอะ<br />
การเปลี่ยนแปลงนิดเดียวอาจได้ผลที่น่าแปลกใจ<br />
<span id="more-444"></span></p>
<p>ปกติส่วนมากเราจะ query แบบนี้</p>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">&quot;SELECT * FROM table&quot;</span>;
<span style="color: #0000ff;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$result</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;$sql&quot;</span>; <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> Invalid query: &quot;</span> . <a href="http://www.php.net/mysql_error"><span style="color: #000066;">mysql_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$row</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color: #000066;">mysql_fetch_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$result</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0000ff;">$ConcertId</span>=	<span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;ConcertId&quot;</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #0000ff;">$ConcertName</span>=	<span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;ConcertName&quot;</span><span style="color: #66cc66;">&#93;</span>;
<span style="color: #66cc66;">&#125;</span>
<a href="http://www.php.net/mysql_free_result"><span style="color: #000066;">mysql_free_result</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$result</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<pre>ถ้าใช้ mysql_fetch_array จะได้ array ($row) ดังนี้
Array
(
    [0] =&gt; 40
    [ConcertId] =&gt; 40
    [1] =&gt; test1
    [ConcertName] =&gt; test1
)
&nbsp;
ส่วน mysql_fetch_assoc จะได้ array ($row) ดังนี้
Array
(
    [ConcertId] =&gt; 40
    [ConcertName] =&gt; test1
)</pre>
<p>จะทำให้คุณใช้ memory น้อยลงไปอีก เพราะส่วนมากเราใช้ $row["ColumnName"] กันอยู่แล้ว<br />
อีกอย่าง เลิก SELECT * กันเถอะ ให้ SELECT ระบุ Column ที่ต้องการดีกว่า ประหยัด memory ไปได้อีกเยอะเลย</p>
<p><map name='google_ad_map_444_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/444?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_444_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=444&amp;url= http%3A%2F%2Fsixhead.com%2F2009%2F06%2F19%2Fmysql_fetch_assoc-vs-mysql_fetch_array%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2009/06/19/mysql_fetch_assoc-vs-mysql_fetch_array/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Export เป็น Microsoft Word อย่างด่วน</title>
		<link>http://sixhead.com/2008/09/28/easy-export-to-microsoft-word/</link>
		<comments>http://sixhead.com/2008/09/28/easy-export-to-microsoft-word/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 16:17:23 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://sixhead.com/?p=188</guid>
		<description><![CDATA[ระบบ Program หน้า backend ของการเขียนโปรแกรมนั้น โดยทั่วไปแล้วการมี หน้าสรุป, หน้ารายงานข้อมูลต่างๆ ถือเป็นหัวใจสำคัญทีเดียว การสร้างมูลค่าเพิ่ม (ให้งานดูดีมีระดับและได้เงินค่าจ้างเพิ่มขึ้น) ก็คือการสร้างรายงานที่เป็น Microsoft Excel, Microsoft Word นั่นเองเนื่องจาก ไฟล์ 2 ประเภทนี้สามารถส่งต่อไปยังผู้ที่เกี่ยวข้องได้ง่ายกว่า การที่ต้องมานั่ง login ทุกครั้งที่อยากดูข้อมูล พูดมากไปแล้วมาเข้าเรื่องกันเลย คราวนี้ถือเป็นภาคต่อจากบทความ Export เป็น Excel อย่างด่วน บทความนี้ดูตัวอย่าง ได้ที่นี่ มาดู code กัน PHP ส่วนหัวเป็นการสร้าง header เพื่อให้ browser รู้ว่าเอกสารหน้านี้เป็น Microsoft Word &#60;?php $strWordFileName = &#34;Word ไฟล์ง่ายนิดเดียว.doc&#34;; header&#40;&#34;Content-Type: application/vnd.ms-word; name=\&#34;$strWordFileName\&#34;&#34;&#41;; header&#40;&#34;Content-Disposition: inline; filename=\&#34;$strWordFileName\&#34;&#34;&#41;; header&#40;&#34;Pragma: no-cache&#34;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>ระบบ Program หน้า backend ของการเขียนโปรแกรมนั้น โดยทั่วไปแล้วการมี หน้าสรุป, หน้ารายงานข้อมูลต่างๆ ถือเป็นหัวใจสำคัญทีเดียว การสร้างมูลค่าเพิ่ม (ให้งานดูดีมีระดับและได้เงินค่าจ้างเพิ่มขึ้น) ก็คือการสร้างรายงานที่เป็น Microsoft Excel, Microsoft Word นั่นเองเนื่องจาก<br/><span id="more-188"></span> ไฟล์ 2 ประเภทนี้สามารถส่งต่อไปยังผู้ที่เกี่ยวข้องได้ง่ายกว่า การที่ต้องมานั่ง login ทุกครั้งที่อยากดูข้อมูล พูดมากไปแล้วมาเข้าเรื่องกันเลย คราวนี้ถือเป็นภาคต่อจากบทความ <a href="http://sixhead.com/2008/03/06/easy-export-to-excel">Export เป็น Excel อย่างด่วน</a> บทความนี้ดูตัวอย่าง <a href="http://sixhead.com/testrun/php/export/easy-word.php">ได้ที่นี่</a> มาดู code กัน</p>
<p>PHP ส่วนหัวเป็นการสร้าง header เพื่อให้ browser รู้ว่าเอกสารหน้านี้เป็น Microsoft Word
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #0000ff;">$strWordFileName</span>    =    <span style="color: #ff0000;">&quot;Word ไฟล์ง่ายนิดเดียว.doc&quot;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Type: application/vnd.ms-word; name=<span style="color: #000099; font-weight: bold;">\&quot;</span>$strWordFileName<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Disposition: inline; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>$strWordFileName<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Pragma: no-cache&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<p>ส่วนบนของ HTML ด้านล่างนี้ บอกว่าเอกสารต่อไปนี้ชนิดเป็นอะไร ซึ่งก็คือ Microsoft Word นั่นเอง ส่วนเนื้อหากลางๆ หน้าดูให้ดีก็คือ HTML ล้วนๆ
<pre class="html4strict">&nbsp;
<span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html</span></a> xmlns:o=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:office:office&quot;</span>
xmlns:x=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:office:word&quot;</span>
xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/TR/REC-html40&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span>
    <span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html;charset=TIS-620&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span>
&nbsp;
ทดลองสร้างไฟล์ Microsoft Word จาก HTML<span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th</span></a> <span style="color: #000066;">bgcolor</span>=<span style="color: #ff0000;">&quot;#96BB00&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Field<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th</span></a> <span style="color: #000066;">bgcolor</span>=<span style="color: #ff0000;">&quot;#FFFF99&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/b.html"><span style="color: #000000; font-weight: bold;">&lt;b&gt;</span></a></span>Type<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/b&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/th.html"><span style="color: #000000; font-weight: bold;">&lt;th</span></a> <span style="color: #000066;">bgcolor</span>=<span style="color: #ff0000;">&quot;#96BB00&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/b.html"><span style="color: #000000; font-weight: bold;">&lt;b&gt;</span></a></span>Null<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/b&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/th&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/b.html"><span style="color: #000000; font-weight: bold;">&lt;b&gt;</span></a></span>ConnectId<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/b&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>int(10)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>Yes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>MachineName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>varchar(50)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>Yes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>HDModel<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>varchar(50)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span>Yes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span>
&nbsp;
<span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/font.html"><span style="color: #000000; font-weight: bold;">&lt;font</span></a> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">&quot;#339900&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>ใช้งานกับภาษาไทยได้ดีทีเดียว<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/font&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></pre>
<p>จากตัวอย่างจะเห็นได้ง่ายๆ เลยว่าเราพลิกจากหน้า report ธรรมดา สร้างมูลค่าเพิ่มให้มันกลายเป็น Microsoft Word ได้ในพริบตาทีเดียว ดาวน์โหลด <a href="http://sixhead.com/testrun/php/export/easy-word.phps">source code ได้ที่นี่</a></p>
<p><map name='google_ad_map_188_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/188?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_188_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=188&amp;url= http%3A%2F%2Fsixhead.com%2F2008%2F09%2F28%2Feasy-export-to-microsoft-word%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2008/09/28/easy-export-to-microsoft-word/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ลองเล่นกับตัวแปรแบบแปลกๆ</title>
		<link>http://sixhead.com/2008/04/09/php-var-with-other-way/</link>
		<comments>http://sixhead.com/2008/04/09/php-var-with-other-way/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 13:17:47 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[var]]></category>

		<guid isPermaLink="false">http://sixhead.com/?p=42</guid>
		<description><![CDATA[ลองเล่นแปลกๆ กันดูกับตัวแปรใน PHP $DeliveryType = &#34;Mail&#34;; #$DeliveryType = &#34;Messenger&#34;; &#160; $MailCharge = 10; $MessengerCharge = 50; &#160; echo $&#123;$DeliveryType.&#34;Charge&#34;&#125;; ผลลัพท์ ของ script ด้านบนจะเป็น 10 แต่ถ้า เปลี่ยนเป็นแบบนี้ #$DeliveryType = &#34;Mail&#34;; $DeliveryType = &#34;Messenger&#34;; &#160; $MailCharge = 10; $MessengerCharge = 50; &#160; echo $&#123;$DeliveryType.&#34;Charge&#34;&#125;; ผลลัพท์ ของ script ด้านบนจะเป็น 50 คือ php มันจะเอา string มาต่อกันแล้วไปดึงตัวแปรอีกทีถ้านึกภาพไม่ออกมันจะออกมาลักษณะนี้ $&#123;$DeliveryType.&#34;Charge&#34;&#125;; ก็คือ $&#123;Mail.&#34;Charge&#34;&#125;; [...]]]></description>
			<content:encoded><![CDATA[<p>ลองเล่นแปลกๆ กันดูกับตัวแปรใน PHP</p>
<pre class="php"><span style="color: #0000ff;">$DeliveryType</span>		=	<span style="color: #ff0000;">&quot;Mail&quot;</span>;
<span style="color: #808080; font-style: italic;">#$DeliveryType		=	&quot;Messenger&quot;;</span>
&nbsp;
<span style="color: #0000ff;">$MailCharge</span>		=	<span style="color: #cc66cc;">10</span>;
<span style="color: #0000ff;">$MessengerCharge</span>	=	<span style="color: #cc66cc;">50</span>;
&nbsp;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> $<span style="color: #66cc66;">&#123;</span><span style="color: #0000ff;">$DeliveryType</span>.<span style="color: #ff0000;">&quot;Charge&quot;</span><span style="color: #66cc66;">&#125;</span>;</pre>
<p>ผลลัพท์ ของ script ด้านบนจะเป็น<br />
<span id="more-42"></span></p>
<pre>10</pre>
<p>แต่ถ้า เปลี่ยนเป็นแบบนี้</p>
<pre class="php"><span style="color: #808080; font-style: italic;">#$DeliveryType		=	&quot;Mail&quot;;</span>
<span style="color: #0000ff;">$DeliveryType</span>		=	<span style="color: #ff0000;">&quot;Messenger&quot;</span>;
&nbsp;
<span style="color: #0000ff;">$MailCharge</span>		=	<span style="color: #cc66cc;">10</span>;
<span style="color: #0000ff;">$MessengerCharge</span>	=	<span style="color: #cc66cc;">50</span>;
&nbsp;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> $<span style="color: #66cc66;">&#123;</span><span style="color: #0000ff;">$DeliveryType</span>.<span style="color: #ff0000;">&quot;Charge&quot;</span><span style="color: #66cc66;">&#125;</span>;</pre>
<p>ผลลัพท์ ของ script ด้านบนจะเป็น </p>
<pre>50</pre>
<p>คือ php มันจะเอา string มาต่อกันแล้วไปดึงตัวแปรอีกทีถ้านึกภาพไม่ออกมันจะออกมาลักษณะนี้</p>
<pre class="php">$<span style="color: #66cc66;">&#123;</span><span style="color: #0000ff;">$DeliveryType</span>.<span style="color: #ff0000;">&quot;Charge&quot;</span><span style="color: #66cc66;">&#125;</span>;
ก็คือ
$<span style="color: #66cc66;">&#123;</span><a href="http://www.php.net/mail"><span style="color: #000066;">Mail</span></a>.<span style="color: #ff0000;">&quot;Charge&quot;</span><span style="color: #66cc66;">&#125;</span>;
จะได้ตัวแปร <span style="color: #0000ff;">$MailCharge</span> ออกมาในตอนสุดท้าย</pre>
<p>คิดว่าเป็นประโยชน์กับบางงาน ลองเอาไปเล่นดู</p>
<p><map name='google_ad_map_42_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/42?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_42_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=42&amp;url= http%3A%2F%2Fsixhead.com%2F2008%2F04%2F09%2Fphp-var-with-other-way%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2008/04/09/php-var-with-other-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Export เป็น Excel อย่างด่วน</title>
		<link>http://sixhead.com/2008/03/06/easy-export-to-excel/</link>
		<comments>http://sixhead.com/2008/03/06/easy-export-to-excel/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 16:29:55 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[editplus]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[header]]></category>

		<guid isPermaLink="false">http://sixhead.com/2008/03/06/export-to-excel/</guid>
		<description><![CDATA[ในงานหลายๆ งานที่ต้องมีการ export ข้อมูลออกมา เมื่อก่อนงูๆ ปลาๆ แค่ทำเป็น csv ต่อมาเริ่มหาเครื่องมือช่วยแล้วก็ได้ php_writeexcel ดูตัวอย่างการทำงาน ได้ที่นี่ เป็น class ที่ช่วยสร้าง excel จริงๆ ขึ้นมาได้ ซึ่งใช้ได้ดีมากๆ แต่ในบางครั้งแค่ต้องการ export ข้อมูลอย่างเดียวเราสามารถใช้วิธีสร้างไฟล์ excel ง่ายๆ จาก code html ได้เลย ดูตัวอย่าง ได้ที่นี่ มาดู code กัน &#60;? $strExcelFileName = &#34;Excel ไฟล์ง่ายนิดเดียว.xls&#34;; header&#40;&#34;Content-Type: application/x-msexcel; name=\&#34;$strExcelFileName\&#34;&#34;&#41;; header&#40;&#34;Content-Disposition: inline; filename=\&#34;$strExcelFileName\&#34;&#34;&#41;; header&#40;&#34;Pragma: no-cache&#34;&#41;; ?&#62; ส่วนนี้เป็น header ของ server (website) เพื่อบอก client (browser [...]]]></description>
			<content:encoded><![CDATA[<p>ในงานหลายๆ งานที่ต้องมีการ export ข้อมูลออกมา เมื่อก่อนงูๆ ปลาๆ แค่ทำเป็น csv ต่อมาเริ่มหาเครื่องมือช่วยแล้วก็ได้ <a href="http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/">php_writeexcel</a> ดูตัวอย่างการทำงาน <a href="http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/demo/">ได้ที่นี่</a> เป็น class ที่ช่วยสร้าง excel จริงๆ ขึ้นมาได้ ซึ่งใช้ได้ดีมากๆ แต่ในบางครั้งแค่ต้องการ export ข้อมูลอย่างเดียวเราสามารถใช้วิธีสร้างไฟล์ excel ง่ายๆ จาก code html ได้เลย </p>
<p><span id="more-34"></span> ดูตัวอย่าง <a href="http://sixhead.com/testrun/php/export/easy-excel.php">ได้ที่นี่</a> มาดู code กัน </p>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #0000ff;">$strExcelFileName</span>	=	<span style="color: #ff0000;">&quot;Excel ไฟล์ง่ายนิดเดียว.xls&quot;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Type: application/x-msexcel; name=<span style="color: #000099; font-weight: bold;">\&quot;</span>$strExcelFileName<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Content-Disposition: inline; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>$strExcelFileName<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Pragma: no-cache&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
<p>ส่วนนี้เป็น header ของ server (website) เพื่อบอก client (browser IE,FireFox, etc..) ว่าเอกสารที่กำลังเรียกมานี้เป็น excel เรื่อง header นี้ถ้ารักจะเป็น web developer จำเป็นต้องรู้นะครับ ทำอะไรได้มากมายเลย  เช่น debug program ที่เกี่ยวกับ www, debug flash + php ฯลฯ จะทำให้ทำงานได้เร็วขึ้นเยอะ หรือรวมไปถึงเรื่อง hack เลยทีเดียว ไว้เรื่อง header จะขอแยกเป็นอีกเรื่องหนึ่งในภายหลังครับ</p>
<pre class="html4strict"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html</span></a> xmlns:o=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:office:office&quot;</span>
xmlns:x=<span style="color: #ff0000;">&quot;urn:schemas-microsoft-com:office:excel&quot;</span>
xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/TR/REC-html40&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html;charset=tis-620&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">&lt;style</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;SiXhEaD_Excel_Styles&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000; font-weight: bold;">&lt;strong&gt;</span></a></span>ตัวอย่างรายงาน<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;SiXhEaD_Excel&quot;</span> <span style="color: #000066;">align</span>=center x:publishsource=<span style="color: #ff0000;">&quot;Excel&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> x:str <span style="color: #000066;">border</span>=<span style="color: #cc66cc;">0</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #cc66cc;">0</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #cc66cc;">0</span> <span style="color: #000066;">width</span>=<span style="color: #cc66cc;">100</span>% <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;border-collapse: collapse&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span><span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000; font-weight: bold;">&lt;strong&gt;</span></a></span>Id<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span><span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000; font-weight: bold;">&lt;strong&gt;</span></a></span>จังหวัด<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;80&quot;</span> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span><span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000; font-weight: bold;">&lt;strong&gt;</span></a></span>โทรศัพท์<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span>00001<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span>กรุงเทพฯ<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span>0810000000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span>00002<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span>กาญจนบุรี<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=xl2216681 nowrap&gt;</span>0819999999<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></pre>
<p> ส่วนนี้เป็น tag html ล้วนๆ มีสิ่งที่พิเศษอยู่หน่อยตรง 3 บรรทัดแรกที่ระบุว่า รูปแบบของไฟล์นี้เป็น excel</p>
<pre>class=xl2216681</pre>
<p>ใส่เลข random อะไรก็ได้แต่ให้เหมือนกันทั้งหน้า</p>
<p>จะเอาไปใช้งานก็ดูตัวอย่างดีๆ นะครับ tag บางอันถ้าไม่มีก็ยังออกมาเป็น excel ได้ แต่ว่าบาง column ที่มี 0 นำหน้าเลข 0 จะหายไปครับ</p>
<p>ทิ้งท้าย<br />
- <a href="http://sixhead.com/testrun/php/export/easy-excel.phps">source code</a><br />
- ตัว phpmyadmin ที่เราๆ ท่านๆ ใช้กันอยู่ก็ใช้วิธี export ออกเป็น excel ด้วยวิธีนี้เช่นกัน<br />
- ผมแนะนำนะครับว่า พวกไฟล์ทั้งหลายอย่าไปคิดว่ามันเปิดด้วย excel หรือ word ได้เท่านั้น ลองเอา editplus หรือ notepad เปิดไฟล์ .xls ที่ได้จากวิธีการนี้ดูแล้วคุณจะประหลาดใจกับมันครับ เรื่องเปิดไฟล์ใดๆ ด้วย editplus ยังทำให้คุณแปลกใจอะไรได้อีกมากมาย ลองดูแล้วกันครับ</p>
<p><map name='google_ad_map_34_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/34?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_34_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=34&amp;url= http%3A%2F%2Fsixhead.com%2F2008%2F03%2F06%2Feasy-export-to-excel%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2008/03/06/easy-export-to-excel/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ลองเล่นกัน eval()</title>
		<link>http://sixhead.com/2008/02/27/php-eval/</link>
		<comments>http://sixhead.com/2008/02/27/php-eval/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 17:41:02 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[eval]]></category>

		<guid isPermaLink="false">http://sixhead.com/2008/02/27/php-eval/</guid>
		<description><![CDATA[คำจำกัดความแบบให้เข้าใจง่ายๆ เลยก็คือ นำข้อความใน string มารันในแบบ PHP ได้ (ถ้าเป็น javascript, ภาษาอื่นๆ&#160; ก็ทำงานลักษณะเดียวกัน) ยกตัวอย่างง่ายๆ นะครับ ถ้าเราต้องมีสูตรคำนวณหลายๆ สูตรใน 1 project เราก็อาจจะต้องเขียน function สำหรับใช้แต่ละสูตรเลยทีเดียว ทำให้ลำบากมากถ้า project นั้นมีสูตรที่ใช้คำนวณเยอะๆ และยิ่งถ้าต้องสามารถเพิ่มเติมสูตรได้ในอนาคตยิ่งไปกันใหญ่ มาดูตัวอย่างง่ายๆ กันเลย $intN = 10; $strCal = '(($intN-5)^2) + ((10)^2)'; $strCal = preg_replace&#40;&#34;/\((.*?)\^(.*?)\)/&#34;, &#34;pow($1,$2)&#34;, $strCal&#41;; &#160; echo $strCal; echo &#34;\n&#34;; &#160; eval&#40;&#34;\$strCal = $strCal;&#34;&#41;; echo $strCal; ผลการรันโปรแกรมด้านบน pow(($intN-5),2) + pow((10),2) 125 [...]]]></description>
			<content:encoded><![CDATA[<p>คำจำกัดความแบบให้เข้าใจง่ายๆ เลยก็คือ นำข้อความใน string มารันในแบบ PHP ได้ (ถ้าเป็น javascript, ภาษาอื่นๆ&nbsp; ก็ทำงานลักษณะเดียวกัน) ยกตัวอย่างง่ายๆ นะครับ ถ้าเราต้องมีสูตรคำนวณหลายๆ สูตรใน 1 project เราก็อาจจะต้องเขียน function สำหรับใช้แต่ละสูตรเลยทีเดียว</p>
<p><span id="more-28"></span> ทำให้ลำบากมากถ้า project นั้นมีสูตรที่ใช้คำนวณเยอะๆ และยิ่งถ้าต้องสามารถเพิ่มเติมสูตรได้ในอนาคตยิ่งไปกันใหญ่ มาดูตัวอย่างง่ายๆ กันเลย</p>
<pre class="php"><span style="color: #0000ff;">$intN</span>	=	<span style="color: #cc66cc;">10</span>;
<span style="color: #0000ff;">$strCal</span>	=	<span style="color: #ff0000;">'(($intN-5)^2) + ((10)^2)'</span>;
<span style="color: #0000ff;">$strCal</span>	=	<a href="http://www.php.net/preg_replace"><span style="color: #000066;">preg_replace</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/<span style="color: #000099; font-weight: bold;">\(</span>(.*?)<span style="color: #000099; font-weight: bold;">\^</span>(.*?)<span style="color: #000099; font-weight: bold;">\)</span>/&quot;</span>, <span style="color: #ff0000;">&quot;pow($1,$2)&quot;</span>, <span style="color: #0000ff;">$strCal</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$strCal</span>;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<a href="http://www.php.net/eval"><span style="color: #000066;">eval</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>strCal = $strCal;&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$strCal</span>;</pre>
<p>ผลการรันโปรแกรมด้านบน</p>
<pre>
pow(($intN-5),2) + pow((10),2)
125
</pre>
<p>อธิบายการทำงานดังนี้<br />
1. จากตัวอย่างเรามี ค่า input คือ $intN โดยมีสูตรคือ (($intN-5)^2) + ((10)^2)<br />
2. ใน PHP ถ้าจะยกกำลังต้องแปลง ^ ให้เป็น function pow() เสียก่อน ก็เลยใช้ regular expression (preg_replace) เข้าช่วย<br />
3. การ echo รอบแรกเพื่อแสดงสูตรที่เปลี่ยนเป็นค่า pow ไปแล้วและพร้อมทำการคำนวณ<br />
4. eval เป็นการสั่งให้ ตัวแปร $strCal นั้นทำการรับค่าจาก $strCal ตัวที่เป็นสูตรอีกที (พอดีตั้งตัวแปรซ้ำกันจะได้ไม่เปลือง)<br />
5. echo รอบ 2 ก็แสดงผลที่ได้จากการสั่ง eval นั่นเอง</p>
<p>ทีนี้การประยุกต์ใช้เหรอครับ จะมีกี่สูตรก็ไม่สนใจแล้ว เก็บแต่ละสูตรลง database ไปเลย แต่อาจจะต้องมีหน้า ทดสอบการรันสูตรใน backend ด้วย จะได้ตรวจสอบการทำงาน ว่าทำได้ถูกต้องหรือไม่</p>
<p><map name='google_ad_map_28_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/28?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_28_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=28&amp;url= http%3A%2F%2Fsixhead.com%2F2008%2F02%2F27%2Fphp-eval%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2008/02/27/php-eval/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP+MSSQL กับ last insert id</title>
		<link>http://sixhead.com/2008/02/21/php-and-mssql-with-last-insert-id/</link>
		<comments>http://sixhead.com/2008/02/21/php-and-mssql-with-last-insert-id/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 20:01:36 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://sixhead.com/2008/02/21/phpmssql-%e0%b8%81%e0%b8%b1%e0%b8%9a-last-insert-id/</guid>
		<description><![CDATA[ถ้า PHP+MySQL สามารถใช้ function mysql_insert_id() ได้เลย แล้วถ้า PHP+MSSQL หล่ะให้ทำยังไงดี? ผมมีตัวอย่างอยู่คิดว่าน่าจะมีประโยชน์ครับ $strSql = &#34; INSERT INTO Member (UserId,FirstName,LastName,Email,AddDate) VALUES ('$sUserId','$FirstName','$LastName','$Email','$AddDate') &#34;; mssql_query&#40;$strSql&#41;; &#160; $strSql = &#34;SELECT @@IDENTITY AS LastId&#34;; $objResult = mssql_query&#40;$strSql&#41;; if &#40;!$objResult&#41; &#123; echo &#34;$strSql&#34;; exit; &#125; while&#40;$row = mssql_fetch_array&#40;$objResult&#41;&#41; &#123; $LastId = $row&#91;LastId&#93;; &#125; mssql_free_result&#40;$objResult&#41;;]]></description>
			<content:encoded><![CDATA[<p>ถ้า PHP+MySQL สามารถใช้ function mysql_insert_id() ได้เลย แล้วถ้า PHP+MSSQL หล่ะให้ทำยังไงดี? ผมมีตัวอย่างอยู่คิดว่าน่าจะมีประโยชน์ครับ</p>
<p><span id="more-26"></span></p>
<pre class="php"><span style="color: #0000ff;">$strSql</span> = <span style="color: #ff0000;">&quot;
INSERT INTO Member
(UserId,FirstName,LastName,Email,AddDate) VALUES
('$sUserId','$FirstName','$LastName','$Email','$AddDate')
&quot;</span>;
mssql_query<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$strSql</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0000ff;">$strSql</span> = <span style="color: #ff0000;">&quot;SELECT @@IDENTITY AS LastId&quot;</span>;
<span style="color: #0000ff;">$objResult</span> = mssql_query<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$strSql</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$objResult</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;$strSql&quot;</span>; <a href="http://www.php.net/exit"><span style="color: #000066;">exit</span></a>; <span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$row</span> = mssql_fetch_array<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$objResult</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #0000ff;">$LastId</span>	=	<span style="color: #0000ff;">$row</span><span style="color: #66cc66;">&#91;</span>LastId<span style="color: #66cc66;">&#93;</span>;
<span style="color: #66cc66;">&#125;</span>
mssql_free_result<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$objResult</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p><map name='google_ad_map_26_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/26?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_26_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=26&amp;url= http%3A%2F%2Fsixhead.com%2F2008%2F02%2F21%2Fphp-and-mssql-with-last-insert-id%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2008/02/21/php-and-mssql-with-last-insert-id/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>phpThumb() สร้าง thumbnails ด้วย PHP โดยใช้ GD หรือ ImageMagick</title>
		<link>http://sixhead.com/2008/02/03/phpthumb-thumbnails-created-by-php-using-gd-andor-imagemagik/</link>
		<comments>http://sixhead.com/2008/02/03/phpthumb-thumbnails-created-by-php-using-gd-andor-imagemagik/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 14:34:42 +0000</pubDate>
		<dc:creator>Pipo</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[phpthumb]]></category>

		<guid isPermaLink="false">http://sixhead.com/2008/02/03/phpthumb-%e0%b8%aa%e0%b8%a3%e0%b9%89%e0%b8%b2%e0%b8%87-thumbnails-%e0%b8%94%e0%b9%89%e0%b8%a7%e0%b8%a2-php-%e0%b9%82%e0%b8%94%e0%b8%a2%e0%b9%83%e0%b8%8a%e0%b9%89-gd-%e0%b8%ab%e0%b8%a3%e0%b8%b7/</guid>
		<description><![CDATA[phpThumb เป็น โปรแกรมนึงที่น่าสนใจมีหน้าทีทำการ resize รูปให้เรา (สร้างเป็น thumbnail นั่นเอง) โดยตัวมันเองสามารถทำได้หลายอย่างมาก เช่น - กำหนดความกว้าง x ยาวของรูป - ใส่ watermark ได้ - กำหนดคุณภาพของภาพทำการที่ resize ได้ - ออกมาเป็นภาพ transparent ได้ - rotated - crop - เติมสี background ได้ (กรณีที่เราขยายรูปให้ใหญ่กว่าต้นฉบับ) - อื่นๆ อีกมาก ลองไปดูตัวอย่างจากเจ้าของเวปเขาเลยดีกว่า ตัวอย่างจากเวป &#60;img alt=&#34;&#34; src=&#34;../phpThumb.php?src=images/loco.jpg&#38;amp;w=200&#38;amp;h=300&#38;amp;far=1&#38;amp;bg=CCCCCC&#34; /&#62; จากตัวอย่างการเรียกใช้จะเห็นได้ว่าง่ายมากๆ แค่เติม parameter ต่อท้ายเข้าไปเช่น ตัวอย่างนี้คือ นำรูป images/logo.jpg ให้กว้าง 200 x 300 [...]]]></description>
			<content:encoded><![CDATA[<p><b>phpThumb </b>เป็น โปรแกรมนึงที่น่าสนใจมีหน้าทีทำการ resize รูปให้เรา (สร้างเป็น thumbnail นั่นเอง)<br />
โดยตัวมันเองสามารถทำได้หลายอย่างมาก เช่น<br />
- กำหนดความกว้าง x ยาวของรูป<br />
- ใส่ watermark ได้<br />
- กำหนดคุณภาพของภาพทำการที่ resize ได้<br />
- ออกมาเป็นภาพ transparent ได้<br />
- rotated<br />
- crop<br />
- เติมสี background ได้ (กรณีที่เราขยายรูปให้ใหญ่กว่าต้นฉบับ)<br />
- อื่นๆ อีกมาก<br />
<span id="more-16"></span><br />
ลองไปดูตัวอย่างจากเจ้าของเวปเขาเลยดีกว่า <a href="http://phpthumb.sourceforge.net/demo/demo/phpThumb.demo.demo.php">ตัวอย่างจากเวป</a></p>
<pre class="html4strict"><span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;../phpThumb.php?src=images/loco.jpg&amp;amp;w=200&amp;amp;h=300&amp;amp;far=1&amp;amp;bg=CCCCCC&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre>
<p>จากตัวอย่างการเรียกใช้จะเห็นได้ว่าง่ายมากๆ แค่เติม parameter ต่อท้ายเข้าไปเช่น ตัวอย่างนี้คือ<br />
นำรูป images/logo.jpg ให้กว้าง 200 x 300 px และ มี background สี CCCCCC<br />
ตัวโปรแกรมเองเมื่อทำการ สร้าง thumbnail แล้วจะทำเป็น cache ไฟล์ไว้ด้วย ทำให้ครั้งต่อไปที่มีคนเรียกรูปเดิม<br />
server จะไม่ต้องทำงานหนักเท่าครั้งแรกที่ต้องไปทำการ resize รูปใหม่</p>
<p><a href="http://phpthumb.sourceforge.net/#download">สามารถ download ได้ที่นี่</a></p>
<p>เมื่อ download มาแล้วจะมี folder ชื่อ phpThumb ข้างในจะมีไฟล์ phpThumb.config.php.default<br />
ให้ copy เป็น  phpThumb.config.php เมื่อ upload ขึ้นไปให้ chmod folder phpThumb/cache<br />
ให้เป็นmode 777 ด้วยจะได้สามารถเก็บ cache ของ thumbnail ได้ &nbsp;</p>
<pre class="php"><ol start="54"><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">$PHPTHUMB_CONFIG</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'cache_maxage'</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #cc66cc;">86400</span> * <span style="color: #cc66cc;">30</span>;</div></li></ol></pre>
<p>ถ้าอยากให้เก็บ cache ไว้นานๆ ให้แก้ตรง 30 เป็นจำนวนวันที่ต้องการ</p>
<p>* มีข้อเสนอแนะเพิ่มเติมว่า ไม่เหมาะกับเวปที่มีคนเข้าเยอะๆ เพราะตัว script เองจะทำงานหนักเมื่อมี<br />
รูปใหม่ (ถ้าเวปมีคนเข้าเยอะๆใช้ script ที่ crop รูปตั้งแต่แรกเลยดีกว่า) แต่จะเหมาะกับระบบที่มีรูป<br />
และคนเข้าพอประมาณไม่เยอะมากเช่นระบบ shopping, ระบบ intranet หรือถ้าใคร server แรงลองดูหน่อย<br />
ก็ได้ว่าระบบ cache เขาทำมาดีไหม</p>
<p><map name='google_ad_map_16_f21c57aff87a446f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/16?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_16_f21c57aff87a446f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=16&amp;url= http%3A%2F%2Fsixhead.com%2F2008%2F02%2F03%2Fphpthumb-thumbnails-created-by-php-using-gd-andor-imagemagik%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://sixhead.com/2008/02/03/phpthumb-thumbnails-created-by-php-using-gd-andor-imagemagik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
