<?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>Invinciblebrain.com &#187; php &amp; mysql</title>
	<atom:link href="http://invinciblebrain.com/tag/php-mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://invinciblebrain.com</link>
	<description>behold the power of ideas!</description>
	<lastBuildDate>Thu, 08 Jul 2010 17:10:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
    <title>Invinciblebrain.com</title>
    <url>http://invinciblebrain.com/feed-logo.png</url>
    <link>http://invinciblebrain.com</link>
    <width>122</width>
    <height>130</height>
    <description>Invinciblebrain.com - http://invinciblebrain.com</description>
    </image>		<item>
		<title>POST &#8211; Review</title>
		<link></link>
		<comments>http://invinciblebrain.com/whats-making-news/post-review.php#comments</comments>
		<pubDate>Sun, 21 Jun 2009 18:29:56 +0000</pubDate>
		<dc:creator>InvincibleBrain</dc:creator>
				<category><![CDATA[invinciblebrain]]></category>
		<category><![CDATA[php & mysql]]></category>
		<category><![CDATA[php mysql technology]]></category>
		<category><![CDATA[POST - Review]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://invinciblebrain.com/?p=120</guid>
		<description><![CDATA[POST &#8211; Review In our PHP Forms Lesson we used the post method. This is what the pertinent line of HTML code looked like: HTML Code Excerpt: &#60;form action=&#8221;process.php&#8221; method=&#8221;post&#8221;&#62; &#60;select name=&#8221;item&#8221;&#62; &#8230; &#60;input name=&#8221;quantity&#8221; type=&#8221;text&#8221; /&#62; This HTML code specifies that the form data will be submitted to the &#8220;process.php&#8221; web page using the [...]]]></description>
			<content:encoded><![CDATA[<p>POST &#8211; Review</p>
<p>In our PHP Forms Lesson we used the post method. This is what the pertinent line of HTML code looked like:<br />
HTML Code Excerpt:</p>
<p>&lt;form action=&#8221;process.php&#8221; method=&#8221;post&#8221;&gt;<br />
&lt;select name=&#8221;item&#8221;&gt;<br />
&#8230;<br />
&lt;input name=&#8221;quantity&#8221; type=&#8221;text&#8221; /&gt;</p>
<p>This HTML code specifies that the form data will be submitted to the &#8220;process.php&#8221; web page using the POST method. The way that PHP does this is to store all the &#8220;posted&#8221; values into an associative array called &#8220;$_POST&#8221;. Be sure to take notice the names of the form data names, as they represent the keys in the &#8220;$_POST&#8221; associative array.</p>
<p>Now that you know about associative arrays, the PHP code from &#8220;process.php&#8221; should make a litte more sense.<br />
PHP Code Excerpt:</p>
<p>$quantity = $_POST['quantity'];<br />
$item = $_POST['item'];</p>
<p>The form names are used as the keys in the associative array, so be sure that you never have two input items in your HTML form that have the same name. If you do, then you might see some problems arise.<br />
PHP &#8211; GET</p>
<p>As we mentioned before, the alternative to the post method is get. If we were to change our HTML form to the get method, it would look like this:<br />
HTML Code Excerpt:</p>
<p>&lt;form action=&#8221;process.php&#8221; method=&#8221;get&#8221;&gt;<br />
&lt;select name=&#8221;item&#8221;&gt;<br />
&#8230;<br />
&lt;input name=&#8221;quantity&#8221; type=&#8221;text&#8221; /&gt;</p>
<p>The get method is different in that it passes the variables along to the &#8220;process.php&#8221; web page by appending them onto the end of the URL. The URL, after clicking submit, would have this added on to the end of it:</p>
<p>&#8220;?item=##&amp;quantity=##&#8221;</p>
<p>The question mark &#8220;?&#8221; tells the browser that the following items are variables. Now that we changed the method of sending information on &#8220;order.html&#8221;, we must change the &#8220;process.php&#8221; code to use the &#8220;$_GET&#8221; associative array.<br />
PHP Code Excerpt:</p>
<p>$quantity = $_GET['quantity'];<br />
$item = $_GET['item'];</p>
<p>After changing the array name the script will function properly. Using the get method displays the variable information to your visitor, so be sure you are not sending password information or other sensitive items with the get method. You would not want your visitors seeing something they are not supposed to!</p>
]]></content:encoded>
			<wfw:commentRss>http://invinciblebrain.com/whats-making-news/post-review.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; While Loop and Do While Loop Contrast</title>
		<link></link>
		<comments>http://invinciblebrain.com/whats-making-news/php-while-loop-and-do-while-loop-contrast.php#comments</comments>
		<pubDate>Sun, 21 Jun 2009 18:28:11 +0000</pubDate>
		<dc:creator>InvincibleBrain</dc:creator>
				<category><![CDATA[invinciblebrain]]></category>
		<category><![CDATA[php & mysql]]></category>
		<category><![CDATA[php mysql technology]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://invinciblebrain.com/?p=117</guid>
		<description><![CDATA[A simple example that illustrates the difference between these two loop types is a conditional statement that is always false. First the while loop: PHP Code: $cookies = 0; while($cookies &#62; 1){ echo &#8220;Mmmmm&#8230;I love cookies! *munch munch munch*&#8221;; } Display: As you can see, this while loop&#8217;s conditional statement failed (0 is not greater [...]]]></description>
			<content:encoded><![CDATA[<p>A simple example that illustrates the difference between these two loop types is a conditional statement that is always false. First the while loop:<br />
PHP Code:</p>
<p>$cookies = 0;<br />
while($cookies &gt; 1){<br />
echo &#8220;Mmmmm&#8230;I love cookies! *munch munch munch*&#8221;;<br />
}</p>
<p>Display:</p>
<p>As you can see, this while loop&#8217;s conditional statement failed (0 is not greater than 1), which means the code within the while loop was not executed. Now, can you guess what will happen with a do-while loop?<br />
PHP Code:</p>
<p>$cookies = 0;<br />
do {<br />
echo &#8220;Mmmmm&#8230;I love cookies! *munch munch munch*&#8221;;<br />
} while ($cookies &gt; 1);</p>
<p>Display:<br />
Mmmmm&#8230;I love cookies! *munch munch munch*</p>
<p>The code segment &#8220;Mmmm&#8230;I love cookies!&#8221; was executed even though the conditional statement was false. This is because a do-while loop first do&#8217;s and secondly checks the while condition!</p>
<p>Chances are you will not need to use a do while loop in most of your PHP programming, but it is good to know it&#8217;s there!</p>
]]></content:encoded>
			<wfw:commentRss>http://invinciblebrain.com/whats-making-news/php-while-loop-and-do-while-loop-contrast.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP For Each</title>
		<link></link>
		<comments>http://invinciblebrain.com/whats-making-news/php-for-each.php#comments</comments>
		<pubDate>Sun, 21 Jun 2009 18:27:01 +0000</pubDate>
		<dc:creator>InvincibleBrain</dc:creator>
				<category><![CDATA[invinciblebrain]]></category>
		<category><![CDATA[php & mysql]]></category>
		<category><![CDATA[PHP For Each: Example]]></category>
		<category><![CDATA[php mysql technology]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://invinciblebrain.com/?p=115</guid>
		<description><![CDATA[We have an associative array that stores the names of people in our company as the keys with the values being their age. We want to know how old everyone is at work so we use a Foreach loop to print out everyone&#8217;s name and age. PHP Code: $employeeAges; $employeeAges["Lisa"] = "28"; $employeeAges["Jack"] = "16"; [...]]]></description>
			<content:encoded><![CDATA[<h1></h1>
<p>We have an associative array that stores the names of people in our company as the keys with the values being their age.  We want to know how old everyone is at work so we use a <em>Foreach</em> loop to print out everyone&#8217;s name and age.</p>
<div>
<h2>PHP Code:</h2>
<pre>$employeeAges;
$employeeAges["Lisa"] = "28";
$employeeAges["Jack"] = "16";
$employeeAges["Ryan"] = "35";
$employeeAges["Rachel"] = "46";
$employeeAges["Grace"] = "34";

foreach( $employeeAges as $key =&gt; $value){
	echo "Name: $key, Age: $value &lt;br /&gt;";
}</pre>
</div>
<h2>Display:</h2>
<div>Name: Lisa, Age: 28<br />
Name: Jack, Age: 16<br />
Name: Ryan, Age: 35<br />
Name: Rachel, Age: 46<br />
Name: Grace, Age: 34</div>
<p>The syntax of the <em>foreach</em> statement is a little strange, so let&#8217;s talk about it some.</p>
<h1>Foreach Syntax: $something as $key =&gt; $value</h1>
<p>This crazy statement roughly translates into: For each element of the $employeeAges associative array I want to refer to the <em>key</em> as $key and the <em>value</em> as $value.</p>
<p>The operator &#8220;=&gt;&#8221; represents the relationship between a <em>key</em> and <em>value</em>.  You can imagine that the key points =&gt; to the value.  In our example we named the <em>key</em> $key and the <em>value</em> $value. However, it might be easier to think of it as $name and $age.  Below our example does this and notice how the output is identical because we only changed the variable names that refer to the keys and values.</p>
<div>
<h2>PHP Code:</h2>
<pre>$employeeAges;
$employeeAges["Lisa"] = "28";
$employeeAges["Jack"] = "16";
$employeeAges["Ryan"] = "35";
$employeeAges["Rachel"] = "46";
$employeeAges["Grace"] = "34";

foreach( $employeeAges as $name =&gt; $age){
	echo "Name: $name, Age: $age &lt;br /&gt;";
}</pre>
</div>
<h2>Display:</h2>
<div>Name: Lisa, Age: 28<br />
Name: Jack, Age: 16<br />
Name: Ryan, Age: 35<br />
Name: Rachel, Age: 46<br />
Name: Grace, Age: 34</div>
]]></content:encoded>
			<wfw:commentRss>http://invinciblebrain.com/whats-making-news/php-for-each.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; For Loop</title>
		<link></link>
		<comments>http://invinciblebrain.com/whats-making-news/php-for-loop.php#comments</comments>
		<pubDate>Sun, 21 Jun 2009 18:25:07 +0000</pubDate>
		<dc:creator>InvincibleBrain</dc:creator>
				<category><![CDATA[invinciblebrain]]></category>
		<category><![CDATA[PHP  For Loop]]></category>
		<category><![CDATA[php & mysql]]></category>
		<category><![CDATA[php mysql technology]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://invinciblebrain.com/?p=113</guid>
		<description><![CDATA[The for loop is simply a while loop with a bit more code added to it. The common tasks that are covered by a for loop are: Set a counter variable to some initial value. Check to see if the conditional statement is true. Execute the code within the loop. Increment a counter at the [...]]]></description>
			<content:encoded><![CDATA[<h1></h1>
<p>The for loop is simply a while loop with a bit more code added to it. The  common tasks that are covered by a for loop are:</p>
<ol>
<li>Set a counter variable to some initial value.</li>
<li>Check to see if the conditional statement is true.</li>
<li>Execute the code within the loop.</li>
<li>Increment a counter at the end of each iteration through the loop.</li>
</ol>
<p>The <em>for loop</em> allows you to define these steps in one easy line of  code. It may seem to have a strange form, so pay close attention to the syntax  used!</p>
<h1>For Loop Example</h1>
<h1>The basic structure of the for loop is as follows:</h1>
<div>
<h2>Pseudo PHP Code:</h2>
<pre>for ( initialize a counter; conditional statement; increment a counter){
	do this code;
}</pre>
</div>
<p>Notice how all the steps of the loop are taken care of in the <em>for loop</em> statement. Each step is separated by a semicolon: initiliaze counter,  conditional statement, and the counter increment. A semicolon is needed because  these are separate expressions. However, notice that a semicolon is not needed  after the &#8220;increment counter&#8221; expression.</p>
<p>Here is the example of the brush prices done with a <em>for loop</em> .</p>
<div>
<h2>PHP Code:</h2>
<pre>$brush_price = 5; 

echo "&lt;table border=\"1\" align=\"center\"&gt;";
echo "&lt;tr&gt;&lt;th&gt;Quantity&lt;/th&gt;";
echo "&lt;th&gt;Price&lt;/th&gt;&lt;/tr&gt;";
for ( $counter = 10; $counter &lt;= 100; $counter += 10) {
	echo "&lt;tr&gt;&lt;td&gt;";
	echo $counter;
	echo "&lt;/td&gt;&lt;td&gt;";
	echo $brush_price * $counter;
	echo "&lt;/td&gt;&lt;/tr&gt;";
}
echo "&lt;/table&gt;";</pre>
</div>
<h2>Display:</h2>
<div>
<table border="1" align="center">
<tbody>
<tr>
<th>Quantity</th>
<th>Price</th>
</tr>
<tr>
<td>10</td>
<td>50</td>
</tr>
<tr>
<td>20</td>
<td>100</td>
</tr>
<tr>
<td>30</td>
<td>150</td>
</tr>
<tr>
<td>40</td>
<td>200</td>
</tr>
<tr>
<td>50</td>
<td>250</td>
</tr>
<tr>
<td>60</td>
<td>300</td>
</tr>
<tr>
<td>70</td>
<td>350</td>
</tr>
<tr>
<td>80</td>
<td>400</td>
</tr>
<tr>
<td>90</td>
<td>450</td>
</tr>
<tr>
<td>100</td>
<td>500</td>
</tr>
</tbody>
</table>
</div>
<p>It is important to note that both the <em>for loop</em> and <em>while loop</em> implementation of the price chart table are both OK at getting the job done.  However, the for loop is somewhat more compact and would be preferable in this  situation. In later lessons we will see where the <em>while loop</em> should be  used instead of the for loop.</p>
]]></content:encoded>
			<wfw:commentRss>http://invinciblebrain.com/whats-making-news/php-for-loop.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP  While Loop</title>
		<link></link>
		<comments>http://invinciblebrain.com/whats-making-news/php-while-loop.php#comments</comments>
		<pubDate>Sun, 21 Jun 2009 18:22:43 +0000</pubDate>
		<dc:creator>InvincibleBrain</dc:creator>
				<category><![CDATA[invinciblebrain]]></category>
		<category><![CDATA[PHP  While Loop]]></category>
		<category><![CDATA[php & mysql]]></category>
		<category><![CDATA[php mysql technology]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://invinciblebrain.com/?p=110</guid>
		<description><![CDATA[PHP &#8211; While Loop Repetitive tasks are always a burden to us. Deleting spam email, sealing 50 envelopes, and going to work are all examples of tasks that are repeated. The nice thing about programming is that you can avoid such repetitive tasks with a little bit of extra thinking. Most often these repetitive tasks [...]]]></description>
			<content:encoded><![CDATA[<h1>PHP &#8211; While Loop</h1>
<p>Repetitive tasks are always a burden to us. Deleting spam email, sealing 50  envelopes, and going to work are all examples of tasks that are repeated. The  nice thing about programming is that you can avoid such repetitive tasks with a  little bit of extra thinking. Most often these repetitive tasks are conquered in  the <em>loop</em>.</p>
<p>The idea of a loop is to do something over and over again until the task has  been completed. Before we show a real example of when you might need one, let&#8217;s  go over the structure of the PHP while loop.</p>
<h1>Simple While Loop Example</h1>
<p>The function of the while loop is to do a task over and over as long as the  specified conditional statement is <em>true</em>.  Here is the basic  structure of a PHP while loop:</p>
<div>
<h2>Pseudo PHP Code:</h2>
<pre>while ( conditional statement is true){
	//do this code;
}</pre>
</div>
<p>This isn&#8217;t valid PHP code, but it displays how the while loop is structured.  Here is the break down of how a while loop functions when your script is  executing:</p>
<ol>
<li>The conditional statement is checked. If it is true, then (2) occurs. If    it is false, then (4) occurs.</li>
<li>The code within the while loop is executed.</li>
<li>The process starts again at (1). Effectively &#8220;looping&#8221; back.</li>
<li>If the conditional statement is false, then the code within is not    executed and there is no more looping. The code following the while loop is    then executed like normal.</li>
</ol>
<h1>A Real While Loop Example</h1>
<p>Imagine that you are running an art supply store. You would like to print out  the price chart for number of brushes and total cost. You sell brushes at a flat  rate, but would like to display how much different quantities would cost. This  will save your customers from having to do the mental math themselves.</p>
<p>You know that a while loop would be perfect for this repetitive and boring  task. Here is how to go about doing it.</p>
<div>
<h2>Pseudo PHP Code:</h2>
<pre>$brush_price = 5;
$counter = 10;

echo "&lt;table border=\"1\" align=\"center\"&gt;";
echo "&lt;tr&gt;&lt;th&gt;Quantity&lt;/th&gt;";
echo "&lt;th&gt;Price&lt;/th&gt;&lt;/tr&gt;";
while ( $counter &lt;= 100 ) {
	echo "&lt;tr&gt;&lt;td&gt;";
	echo $counter;
	echo "&lt;/td&gt;&lt;td&gt;";
	echo $brush_price * $counter;
	echo "&lt;/td&gt;&lt;/tr&gt;";
	$counter = $counter + 10;
}
echo "&lt;/table&gt;";</pre>
</div>
<h2>Display:</h2>
<div>
<table border="1" align="center">
<tbody>
<tr>
<th>Quantity</th>
<th>Price</th>
</tr>
<tr>
<td>10</td>
<td>50</td>
</tr>
<tr>
<td>20</td>
<td>100</td>
</tr>
<tr>
<td>30</td>
<td>150</td>
</tr>
<tr>
<td>40</td>
<td>200</td>
</tr>
<tr>
<td>50</td>
<td>250</td>
</tr>
<tr>
<td>60</td>
<td>300</td>
</tr>
<tr>
<td>70</td>
<td>350</td>
</tr>
<tr>
<td>80</td>
<td>400</td>
</tr>
<tr>
<td>90</td>
<td>450</td>
</tr>
<tr>
<td>100</td>
<td>500</td>
</tr>
</tbody>
</table>
</div>
<p>Pretty neat, huh? The loop created a new table row and its respective entries  for each quantity, until our counter variable grew past the size of 100. When it  grew past 100 our conditional statement failed and the loop stopped being used.  Let&#8217;s review what is going on.</p>
<ol>
<li>We first made a $brush_price and $counter variable and set them equal to    our desired values.</li>
<li>The table was set up with the beginning table tag and the table headers.</li>
<li>The while loop <em>conditional statement</em> was checked, and $counter (10)    was indeed smaller or equal to 100.</li>
<li>The code inside the while loop was executed, creating a new table row for    the price of 10 brushes.</li>
<li>We then added 10 to $counter to bring the value to 20.</li>
<li>The loop started over again at step 3, until $counter grew larger than    100.</li>
<li>After the loop had completed, we ended the table.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://invinciblebrain.com/whats-making-news/php-while-loop.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
