<?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>php mysql array - TsupamaN.com</title>
	<atom:link href="https://www.tsupaman.com/tag/php-mysql-array/feed" rel="self" type="application/rss+xml" />
	<link>https://www.tsupaman.com/tag/php-mysql-array</link>
	<description>ทำเว็บไซต์ด้วย Wordpress</description>
	<lastBuildDate>Tue, 01 Jul 2014 18:26:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>PHP : MySQL การนำค่าจากอาเรย์มาแสดง</title>
		<link>https://www.tsupaman.com/2014/02/php-mysql-array-show</link>
		
		<dc:creator><![CDATA[TsupamaN]]></dc:creator>
		<pubDate>Mon, 17 Feb 2014 02:52:31 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[mysql รับค่า array]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[PHP MySQL]]></category>
		<category><![CDATA[php mysql array]]></category>
		<category><![CDATA[php mysql วนลุบ]]></category>
		<category><![CDATA[การเขียนโปรแกรม]]></category>
		<guid isPermaLink="false">https://www.tsupaman.com/?p=639</guid>

					<description><![CDATA[<p>สำหรับการวนลูปเพื่อให้ได้ค่ามาจากฐานข้อมูลนั้น มีรูปแบบการวนอยู่ดังนี้ &#8211; mysql_fetch_array() , mysql_fetch_assoc() , mysql_fetch_row() ซึ่งในแต่ละแบบ จะมีวิธีใช้ต่างกันที่ทำให้ใครหลายคนตายน้ำตื้นมาแล้ว mysql_fetch_array() เมื่อ เราทำการวนลูป เราจะได้ตัวแปรอาเรย์ที่ชื่อ $row ดังตัวอย่างมาเพื่อแสดงค่า ซึ่งค่า index ใน $row นั้น จะสามารถใส่เป็นตัวเลข หรือชื่อฟิลด์ของฐานข้อมูลก็ได้ ดังนี้ while($row = mysql_fetch_array($result)){ echo $row['num']; } while($row = mysql_fetch_array($result)){ echo $row['1']; } mysql_fetch_assoc() ค่า index ใน $row นั้น จะสามารถใส่เป็นชื่อฟิลด์ของฐานข้อมูลได้เท่านั้น ดังนี้ while($row = mysql_fetch_array($result)){ echo $row['num']; } mysql_fetch_row() ค่า index ใน $row [&#8230;]</p>
<p>The post <a href="https://www.tsupaman.com/2014/02/php-mysql-array-show">PHP : MySQL การนำค่าจากอาเรย์มาแสดง</a> appeared first on <a href="https://www.tsupaman.com">TsupamaN.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div id="stcpDiv">
<p>สำหรับการวนลูปเพื่อให้ได้ค่ามาจากฐานข้อมูลนั้น มีรูปแบบการวนอยู่ดังนี้</p>
<p>&#8211; <strong>mysql_fetch_array() , mysql_fetch_assoc() , mysql_fetch_row()</strong></p>
<p>ซึ่งในแต่ละแบบ จะมีวิธีใช้ต่างกันที่ทำให้ใครหลายคนตายน้ำตื้นมาแล้ว</p>
<p><strong>mysql_fetch_array() เมื่อ เราทำการวนลูป เราจะได้ตัวแปรอาเรย์ที่ชื่อ $row ดังตัวอย่างมาเพื่อแสดงค่า ซึ่งค่า index ใน $row นั้น จะสามารถใส่เป็นตัวเลข หรือชื่อฟิลด์ของฐานข้อมูลก็ได้ ดังนี้<br />
</strong></p>
<pre class="lang:php decode:true">while($row = mysql_fetch_array($result)){
    echo $row['num'];
}</pre>
<pre class="lang:php decode:true">while($row = mysql_fetch_array($result)){
    echo $row['1'];
}</pre>
<p><strong>mysql_fetch_assoc() </strong><strong>ค่า index ใน $row นั้น จะสามารถใส่เป็นชื่อฟิลด์ของฐานข้อมูลได้เท่านั้น ดังนี้</strong></p>
<pre class="lang:php decode:true">while($row = mysql_fetch_array($result)){
    echo $row['num'];
}</pre>
<p><strong>mysql_fetch_row() </strong><strong>ค่า index ใน $row นั้น จะสามารถใส่เป็น</strong><strong>ตัวเลข</strong><strong>ได้เท่านั้น ดังนี้</strong></p>
<pre class="lang:php decode:true crayon-selected">while($row = mysql_fetch_array($result)){
    echo $row['1'];
}</pre>
<p>ระหว่างตัว <strong>mysql_fetch_assoc() , mysql_fetch_row() นั้น หากใส่ไม่สอดคล้องกัน จะทำให้ระบบไม่แสดงข้อมูลออกมา ซึ่งอาจจะเป็นปัญหาที่ไม่ควรมองข้าม หลายๆคนอาจจะนั่งหาข้อผิดพลาดทางด้าน syntax อยู่นาน แต่คิดไม่ถึงว่าจะเป็นแค่การใส่ค่า index ของอาเรย์ให้ถูกเท่านั้น</strong></p>
</div>
<p>The post <a href="https://www.tsupaman.com/2014/02/php-mysql-array-show">PHP : MySQL การนำค่าจากอาเรย์มาแสดง</a> appeared first on <a href="https://www.tsupaman.com">TsupamaN.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
