<?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>Me Like Web</title>
	<atom:link href="http://www.melikeweb.com/feed/tumblog/" rel="self" type="application/rss+xml" />
	<link>http://www.melikeweb.com</link>
	<description>Web Development, PHP, MySQL, tutorials and other random webby ramblings</description>
	<lastBuildDate>Tue, 18 May 2010 22:11:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=3.0</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		
	 
    	<item>
			<title>Day 3: Getting Started with Dynamic Web Development (PHP &amp; MySQL) – PHP For Beginners</title>
			<link>http://www.melikeweb.com/2010/05/day-3-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-php-for-beginners/</link>
			<comments>http://www.melikeweb.com/2010/05/day-3-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-php-for-beginners/#comments</comments>
			<pubDate>Tue, 18 May 2010 22:02:41 +0000</pubDate>
			<dc:creator>me</dc:creator>
					<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Day 3]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
						<guid isPermaLink="false">http://www.melikeweb.com/?p=94</guid>
						<description><![CDATA[<p>Posted in <a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials" rel="category tag">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/web-development-tutorials/" title="View all posts in Web Development" rel="category tag">Web Development</a></p>Welcome back everyone!  By now most of you have become pretty comfortable with the basic concept of how PHP works (at least in the simplest sense) and have had your share of fun with &#8216;echoing&#8217; all kinds of neat little messages all over your pages!  Most of you are also probably wondering how this exercise [...]<p><a href="http://www.melikeweb.com/2010/05/day-3-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-php-for-beginners/#respond" title="Comment on Day 3: Getting Started with Dynamic Web Development (PHP &amp; MySQL) – PHP For Beginners">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials" rel="category tag">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/web-development-tutorials/" title="View all posts in Web Development" rel="category tag">Web Development</a></p><p>Welcome back everyone!  By now most of you have become pretty comfortable with the basic concept of how PHP works (at least in the simplest sense) and have had your share of fun with &#8216;echoing&#8217; all kinds of neat little messages all over your pages!  Most of you are also probably wondering how this exercise is even remotely helpful to you since you are adding a bunch of code to something that can easily be accomplished in plain old HTML&#8230; AND with far less work!  Patience young grasshoppah&#8230; lets walk over that hill and find the answer to your troubles&#8230; Namaste.</p>
<p><strong>BEYOND &#8216;ECHO&#8217;</strong></p>
<p>Now, &#8216;echoing&#8217; some text onto a page might not seem incredibly fascinating, but let&#8217;s take a stab at making it a bit more interesting than simply displaying some text, by taking a look at <strong>variables</strong>.</p>
<p>Most of your entire PHP &#8216;existence&#8217; will revolve around the concept of variables.  For you algebra grads out there, I don&#8217;t have to remind you what variables are, but for those of us who have successfully blocked out most of high school (traumatic experiences will do that to ya), let&#8217;s take 13 seconds to revisit:</p>
<blockquote><p><strong>Variables </strong>are simply placeholders&#8230; think of them as stand-ins for something else.  Variables can be used an unlimited number of times and we can change their actual value at any point&#8230;</p></blockquote>
<p>The way we use variables in PHP is very simple.  In order for PHP to identify a variable it needs to:</p>
<ol>
<li><strong>Be within a PHP code block (i.e. &lt;?php &#8230; ?&gt;)</strong></li>
<li><strong>Start with a &#8216;$&#8217; (dollar sign)</strong></li>
<li><strong>Contain no spaces</strong></li>
</ol>
<p>That&#8217;s it.  Too easy you say?  It sure is!  Now, it should be noted that there are a couple more rules when it comes to variables:</p>
<p><strong>Initial Declaration</strong></p>
<p>Before we can actually use a variable anywhere, we need to <strong>declare</strong> it, or assign it a value.  Once you&#8217;ve declared a variable, you can start using it.</p>
<p>Example (String/Text variable):</p>
<p><code>&lt;?php<br />
$animal="dog";<br />
?&gt; </code></p>
<p>Notice how we&#8217;ve defined the variable, then we&#8217;ve assigned the value &#8220;dog&#8221; to it, by using the &#8216;=&#8217; (equals) sign.</p>
<p>It&#8217;s important to note that since we are assigning text or a &#8216;string&#8217; to this variable, we need to remember to use the &#8220;quotes&#8221; around it.  If this was a numeric variable, we would simply use numbers with no quotes&#8230; more on that later.</p>
<p>Finally, we&#8217;ve finished our declaration, by closing with a &#8216;;&#8217; (semicolon).  That tells PHP that we are finished with that part.</p>
<p><strong>Subsequent Usage</strong></p>
<p>Now that we&#8217;ve declared our variable, let&#8217;s use it for something!</p>
<p>Below is an example of how you could use this variable&#8230; I will show you two ways you can accomplish the exact same thing:</p>
<p>Example 1:</p>
<p><code><strong>&lt;?php<br />
$animal="dog";<br />
?&gt;</strong><br />
My favorite animal is a <strong>&lt;?php echo $animal; ?&gt;</strong>. A <strong>&lt;?php echo $animal; ?&gt;</strong> is man's best friend. </code></p>
<p>Example 2:</p>
<p><code>&lt;?php<br />
<strong>$animal="dog";</strong><br />
echo "My favorite animal is a <strong>$animal</strong>. A <strong>$animal</strong> is man's best friend.";<br />
?&gt; </code></p>
<p>Notice the difference in the code use?  Try this out on your own, testing out both methods. Regardless of which way you go with, both of these examples will give you the exact same results:</p>
<blockquote><p>My favorite animal is a dog. A dog is man&#8217;s best friend.</p></blockquote>
<p>Take a few moments to think about what you just tried.  The concept you should take away from it is this:</p>
<blockquote><p><strong>PHP code can either be sprinkled into your existing HTML, or you can use PHP to generate content as a whole</strong>.</p></blockquote>
<p><strong>One More Thing&#8230;</strong></p>
<p>I really need to point this out before we go any further&#8230; please remember this, write it down, tattoo it onto your arm if you need to:</p>
<blockquote><p><strong>PHP works LINEARLY&#8230; meaning the code is read from start to finish or top to bottom.</strong></p></blockquote>
<p>Keep that very present as you code.  Any variable you declare or initialize, <strong>MUST</strong> be set before you start using it.</p>
<p><strong>Variables as Numbers</strong></p>
<p>Okay, we&#8217;ve now seen an example of variables being used to display text, but what if we wanted to use numbers instead?</p>
<p>Good on Ya!  That&#8217;s the spirit!  Assigning numbers to variables allows us to do much more than simply spit out a sentence or two!  Take a look:</p>
<p>Example (Numeric variable):</p>
<p><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">&lt;?php</span></p>
<p><code><strong>$num1=5;<br />
$num2=10;<br />
$result=$num1+$num2;</strong></code></p>
<div><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;"><strong><code><strong><span style="font-weight: normal; ">echo "Adding <strong>$num1</strong> to <strong>$num2</strong> gives us: </span>$result!<span style="font-weight: normal; ">";</span></strong></code></p>
<p></strong></p>
<p></span></div>
<p><code>?&gt;</code></p>
<p>Try this out on your own.  If you copy/pasted just right, you should get:</p>
<blockquote><p>Adding 5 to 10 gives us: 15!</p></blockquote>
<p>Purty neat huh?  Notice that when we assigned the numbers to our variables, we did not use &#8220;quotes&#8221; to surround those values.  Leaving out the quotes tells PHP that these are values and not just strings of text, which force it to evaluate or calculate the values for us.</p>
<p>Our <strong>$result</strong> variable is where all the magic happens.  Notice how we are able to add the variables together without having to explicitly say: <strong>$result=5+10;</strong> (although that would also work&#8230; but you get the point).</p>
<p><strong>DAY 3 WRAPUP</strong></p>
<p>We&#8217;ll stop right there for today, but as always, the fun doesn&#8217;t have to stop on your end; play with the code and try other variations of it.  Practically every type of calculation can be performed, using the above format.</p>
<p>As a reference to you, here are the very basic operations and how to express them in your code:</p>
<ul>
<li><strong>&#8216;+&#8217; : Adding (i.e. 10+5)</strong></li>
<li><strong>&#8216;-&#8217; : Subtracting (i.e. 10-5)</strong></li>
<li><strong>&#8216;*&#8217; : Multiplying (i.e. 10*5)</strong></li>
<li><strong>&#8216;/&#8217; : Dividing (i.e. 10/5) </strong></li>
</ul>
<p>See you all back here for <strong>Day 4 &#8211; Form Integration</strong>, where we&#8217;ll be dipping our toe into the web2.0 realm and really start looking at how we can not only talk TO our adoring public, but talk WITH them, using basic form integration.</p>
<p>See you all then!</p>
<p><a href="http://www.melikeweb.com/2010/05/day-3-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-php-for-beginners/#respond" title="Comment on Day 3: Getting Started with Dynamic Web Development (PHP &amp; MySQL) – PHP For Beginners">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://www.melikeweb.com/2010/05/day-3-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-php-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>			
    	
		
	 
    	<item>
			<title>Day 2: Getting Started with Dynamic Web Development (PHP &amp; MySQL) – Prep Time</title>
			<link>http://www.melikeweb.com/2010/05/day-2-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-prep-time/</link>
			<comments>http://www.melikeweb.com/2010/05/day-2-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-prep-time/#comments</comments>
			<pubDate>Wed, 12 May 2010 06:39:22 +0000</pubDate>
			<dc:creator>me</dc:creator>
					<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Day 2]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
						<guid isPermaLink="false">http://www.melikeweb.com/?p=79</guid>
						<description><![CDATA[<p>Posted in <a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials" rel="category tag">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/web-development-tutorials/" title="View all posts in Web Development" rel="category tag">Web Development</a></p>Welcome to Day 2 of Dynamic Web Development!  Today we are going to start covering some fun stuff, dabbling with some PHP and getting you set up to the point where you are a bit more dangerous than you were yesterday! If you have not already done so, go ahead and download MAMP (for Mac) [...]<p><a href="http://www.melikeweb.com/2010/05/day-2-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-prep-time/#respond" title="Comment on Day 2: Getting Started with Dynamic Web Development (PHP &amp; MySQL) – Prep Time">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials" rel="category tag">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/web-development-tutorials/" title="View all posts in Web Development" rel="category tag">Web Development</a></p><p>Welcome to <strong>Day 2 of Dynamic Web Development</strong>!  Today we are going to start covering some fun stuff, dabbling with some PHP and getting you set up to the point where you are a bit more dangerous than you were yesterday!</p>
<p>If you have not already done so, go ahead and download <a href="http://www.mamp.info" target="_blank">MAMP (for Mac)</a> or <a href="http://www.wampserver.com/en/download.php" target="_blank">WAMP (for PC)</a>. The download will take a little while, so that will give us a bit of time to talk about what we&#8217;ll be using!</p>
<p><strong>MAMP/WAMP</strong></p>
<p>&#8220;What&#8217;s this funky program I&#8217;m downloading?&#8221; Glad you asked!  Now, while regular HTML pages can be created offline (i.e. right on your computer) and opened up on your favorite browser with no problem, PHP pages are slightly different.  In short, PHP pages are actually scripts, and require some special processing in order for your browser to understand what you are trying to have it display.</p>
<p>MAMP and WAMP are both really cool programs that actually create a kind of enclosed environment within your computer which allows it to act as a mini, full-featured web server!  Both of these are basically bundled with <strong>Apache</strong> (that&#8217;s the web server part), <strong>MySQL</strong> (that&#8217;s your database server) and <strong>PHP</strong> (that&#8217;s the gentle giant that will make all your web dev dreams come true).</p>
<p>Once the program is installed, not only will it interpret your PHP pages and have it display correctly on your browser, but also you&#8217;ll be able to set up some databases for some real dynamic, data-driven fun!</p>
<p><strong>PHP</strong></p>
<p>Okay, let&#8217;s take a look at our primary focus point for now: PHP.  As I mentioned before, PHP pages are scripts.  They look just like HTML pages, but instead of ending in the typical &#8216;<strong>.html</strong>&#8216; or &#8216;<strong>.htm</strong>&#8216; you are probably used to seeing, these end in &#8216;<strong>.php</strong>&#8216;.  It&#8217;s important to understand that there is nothing special that needs to be done to a page in order to make a PHP file; just the fact that a page ends with &#8216;<strong>.php</strong>&#8216; is good enough for your little MAMP or WAMP server to understand that it is a PHP script and should be handled differently than a plain HTML file.</p>
<p>Don&#8217;t be scared away from the term &#8216;script&#8217; either.  Most people immediately think &#8216;program&#8217; when they hear the word script.  You don&#8217;t need to have any programming background or knowledge other than what you already know how to do with HTML (and even if THAT is limited, worry not, young Padawan&#8230; you&#8217;ll be up to speed in no time)!</p>
<p><strong>FIND WALDO</strong></p>
<p>Okay, let&#8217;s connect A and B for you.  Below is an example of a very basic HTML page:</p>
<p><code>&lt;html&gt;<br />
&lt;body&gt;<br />
Hi!  I'm an HTML page!<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
<p>Pretty basic right?</p>
<p>Let me give you an example of an equally basic PHP page:</p>
<p><code>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;?php echo "Hi! I'm a much cooler PHP page!"; ?&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></p>
<p><code> </code></p>
<p>That&#8217;s it!  Now, pretending that the PHP code snippet were Waldo&#8230; can you find him in that second example?  Awesome!  Glad to see all those years of playing off of the back of Life Cereal boxes has finally paid off!</p>
<p><strong>THE SNIPPET&#8230; IT CONFUSES ME</strong></p>
<p>So you&#8217;ve found the snippet&#8230; &#8220;What does it mean?&#8221; It means you&#8217;re not afraid to ask questions&#8230; good for you!</p>
<p>This is where our handy PHP interpreter comes to the rescue.  Unassisted, a browser would display the second example above, exactly like this:</p>
<blockquote><p>&lt;?php echo &#8220;Hi! I&#8217;m a much cooler PHP page!&#8221;; ?&gt;</p></blockquote>
<p>But if we allow our handy little PHP interpreter (AKA: MAMP/WAMP) to take a crack at it, the output would look like:</p>
<blockquote><p>Hi! I&#8217;m a much cooler PHP page!</p></blockquote>
<p><strong>OKAY&#8230; I&#8217;M KINDA FOLLOWIN&#8217;</strong></p>
<p>A PHP page can have all of the usual fun little HTML stuff inside it; tables, images, CSS styling, etc. The difference is that as soon as it runs into anything surrounded by:<br />
<code><br />
&lt;?php ... ?&gt;</code></p>
<p>It immediately switches gears and allows the PHP interpreter to do its thing and &#8216;interpret&#8217; the code inside.  After the interpreter has done it&#8217;s thing, it spits out the &#8216;HTML-friendly&#8217; code, which is then passed along to the browser, who now totally understands what you meant to have it do!</p>
<blockquote><p>It&#8217;s kind of like a translater!</p></blockquote>
<p>Exactly!</p>
<p><strong>BASIC SYNTAX</strong></p>
<p>Now that we&#8217;re all on the same page about who does what and why, let&#8217;s move aside that Baterang, cause we&#8217;re going to start adding a couple of key components to your utility belt (SHAZZAM)!</p>
<p>Let&#8217;s dissect that piece of code we just used:</p>
<p><code>&lt;?php echo "Hi! I'm a much cooler PHP page!"; ?&gt;<br />
</code></p>
<p>Let&#8217;s break it apart:</p>
<p><code><strong>&lt;?php</strong><br />
</code></p>
<p>This is what you will ALWAYS use to start any PHP code block (think of these as parenthesis on steroids).</p>
<p><code><strong>echo</strong></code></p>
<p>The &#8216;echo&#8217; command tells the browser to display the thing next to it.</p>
<p><code><strong>"Hi! I'm a much cooler PHP page!"</strong><br />
</code></p>
<p>Any text you want to display needs to be in double or single quotes (we&#8217;ll talk about the difference, but for now, let&#8217;s keep using doubles).</p>
<p><code><strong>;</strong><br />
</code></p>
<p>The semicolon tells the interpreter that it is finished with that part of the code.</p>
<p><code><strong>?&gt;</strong><br />
</code></p>
<p>And finally, this is what you will ALWAYS use to end any PHP code block (this is the &#8216;closing&#8217; part of our steroid-powered parenthesis&#8230; and just like regular parentheses, always remember to close them after you&#8217;re done using them).</p>
<p><strong>GOT IT! LET&#8217;S GET THIS PARTY STARTED!</strong></p>
<p>Good!  Okay, enough classroom time, let&#8217;s take this magic school bus over to the lab!</p>
<p>By now your MAMP or WAMP download has probably finished up, and if you didn&#8217;t take a break in the middle of our learning annex to run the installer (look at you&#8230; such a good student!), go ahead and do that now!  &#8230; don&#8217;t worry, I&#8217;ll wait.  In fact, I&#8217;ll time ya!  Ready?  Go!</p>
<p><strong>DONE!</strong></p>
<p>Wow, you&#8217;re fast! Hardly broke a sweat, didn&#8217;t ya?  Now that you&#8217;ve got MAMP/WAMP installed and running, fire up the little default page it comes with, just to make sure everything is working correctly.</p>
<p>If you&#8217;re having trouble with the install, try one of these friendly, neighborhood resources to get you through it:</p>
<p>MAMP (Mac): <a href="http://www.mamp.info/en/documentation/" target="_blank">http://www.mamp.info/en/documentation/</a></p>
<p>WAMP (PC): <a href="http://www.tagbytag.org/tutorials/getting-started/web-design-software/wamp-guide" target="_blank">http://www.tagbytag.org/tutorials/getting-started/web-design-software/wamp-guide</a></p>
<p>Once you&#8217;ve got things running, take a couple of minutes to find where on your actual computer the &#8216;root web folder&#8217; is located (Anything you create from here on out, <strong>MUST</strong> be saved within or under this folder, otherwise your browser <strong>WILL NOT</strong> be able to see it)&#8230;</p>
<p>MAMP: /Aplications/MAMP/htdocs/</p>
<p>WAMP: C:/Program Files/wamp/www/</p>
<p>If you are using Dreamweaver or some other HTML editing software, now would be a good time for you to set up a local site and point it to your respective root folder (this will make things much easier for you as we move ahead).</p>
<p><strong>AND IT BEGINS&#8230;</strong></p>
<p>Now that you&#8217;ve got your shiny new web development environment all set up, let&#8217;s take it out for a spin!</p>
<p>From Dreamweaver (or your second favorite HTML editing program), create a <strong>New File</strong> (select &#8216;PHP&#8217; as the file type if prompted) and let&#8217;s save it as: <strong>mypage.php</strong></p>
<p>Now a brand new page will probably look like this in code view:</p>
<p><code> </code></p>
<p><code></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;head&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;title&gt;Untitled Document&lt;/title&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/head&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;body&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/body&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2089px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/html</div>
<p></code></p>
<p><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code><br />
Don&#8217;t worry about all the scattered code. From here on out, your only focus will be what&#8217;s between the &#8216;&lt;body&gt;&lt;/body&gt;&#8217; tags.</p>
<p>Copy/Paste the following PHP code between the &#8216;body&#8217; tags, so it looks like this:</p>
<p><code> &lt;body&gt;<br />
&lt;?php echo "Hi! I'm a much cooler PHP page!"; ?&gt;<br />
&lt;/body&gt;<br />
</code></p>
<p>Then, <strong>SAVE</strong> your page.</p>
<p>From your browser, preferably a separate tab or window (don&#8217;t leave me!), type or click this link:</p>
<p><a href="http://localhost/mypage.php" target="_blank">http://localhost/mypage.php</a></p>
<p>If you are using MAMP and the above link does not work, try:</p>
<p><a href="http://localhost:8888/mypage.php" target="_blank">http://localhost:8888/mypage.php</a></p>
<p>Assuming that you have both saved your file to that root folder you located earlier, and that you named your file: <strong>mypage.php</strong>, you should be staring at the magnificence of your VERY FIRST PHP WEB PAGE!!! (can&#8217;t you just hear the trumpets in the background?), and displayed majestically in front of you should be the phrase:</p>
<blockquote><p>Hi! I&#8217;m a much cooler PHP page!</p></blockquote>
<p>&#8230;oh, yes. That you are&#8230;  That&#8230; you are.</p>
<p><strong>DAY 2 WRAP UP</strong></p>
<p>And believe it or not, just like that, you are well on your way to a bright and much more dynamic web world!</p>
<p>While the example you just tried is very basic, it&#8217;s important that you understand the concept of how PHP pages are written, and what is needed for your browser to understand them.</p>
<p>We are going to stop here for today, but your &#8216;hands on&#8217; session doesn&#8217;t have to!  Feel free to play with the code snippet you just made.  Add tables, pictures or just about any other HTML elements to your page and throw in as many PHP code snippets as you want! The best way to learn, after all, is by doing&#8230; so DO IT!</p>
<p>Tomorrow, we&#8217;ll start looking at some more useful ways of using PHP including using variables and some basic math&#8230; Hey you in the back, I heard that sigh, don&#8217;t worry&#8230; this is the fun kind of math that requires not a single pencil nor piece of paper from you, and will let you do some pretty amazing things.</p>
<p>See you all back here for <strong><a href="/2010/05/day-3-getting-started-with-dynamic-web-development-php-mysql-–-php-for-beginners/">Day 3 &#8211; PHP for Beginners</a></strong>!</p>
<p><a href="http://www.melikeweb.com/2010/05/day-2-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-prep-time/#respond" title="Comment on Day 2: Getting Started with Dynamic Web Development (PHP &amp; MySQL) – Prep Time">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://www.melikeweb.com/2010/05/day-2-getting-started-with-dynamic-web-development-php-mysql-%e2%80%93-prep-time/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>			
    	
		
	 
    	<item>
			<title>Day 1: Getting Started with Dynamic Web Development (PHP &amp; MySQL) &#8211; Introduction</title>
			<link>http://www.melikeweb.com/2010/05/day-1-gettings-started-with-dynamic-web-development-php-mysql-introduction/</link>
			<comments>http://www.melikeweb.com/2010/05/day-1-gettings-started-with-dynamic-web-development-php-mysql-introduction/#comments</comments>
			<pubDate>Tue, 11 May 2010 07:58:18 +0000</pubDate>
			<dc:creator>me</dc:creator>
					<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Day 1]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
						<guid isPermaLink="false">http://www.melikeweb.com/?p=38</guid>
						<description><![CDATA[<p>Posted in <a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials" rel="category tag">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/web-development-tutorials/" title="View all posts in Web Development" rel="category tag">Web Development</a></p>So you&#8217;re dabbling in the world of HTML are ya?  You&#8217;ve got Dreamweaver installed and you&#8217;ve figured out how to make some pretty nice pages with all kinds of cool images and styled fonts and even threw in a table here and there, or even deciphered how that &#8216;in-page&#8217; Dreamweaver CSS code works! By now, the acronym [...]<p><a href="http://www.melikeweb.com/2010/05/day-1-gettings-started-with-dynamic-web-development-php-mysql-introduction/#respond" title="Comment on Day 1: Getting Started with Dynamic Web Development (PHP &amp; MySQL) &#8211; Introduction">Leave a Comment</a></p>]]></description>
						<content:encoded><![CDATA[<p>Posted in <a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials" rel="category tag">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/" title="View all posts in Tutorials">Tutorials</a>,<a href="http://www.melikeweb.com/category/tutorials/web-development-tutorials/" title="View all posts in Web Development" rel="category tag">Web Development</a></p><p>So you&#8217;re dabbling in the world of HTML are ya?  You&#8217;ve got Dreamweaver installed and you&#8217;ve figured out how to make some pretty nice pages with all kinds of cool images and styled fonts and even threw in a table here and there, or even deciphered how that &#8216;in-page&#8217; Dreamweaver CSS code works!</p>
<p>By now, the acronym HTML probably doesn&#8217;t even scare you as much as it did when you started setting up your very first &#8216;Hello World&#8217; page, does it?  But what you&#8217;re really itching to know how to do is how to make your awesome HTML page talk to some data and truly make your page dynamically-driven!</p>
<p>Does this sound like you? If so, let me be the first to welcome you to the wonderful world of &#8216;Data-Driven Website Development&#8217; (insert trumpet fanfare here) using <strong>PHP</strong> and <strong>MySQL</strong>!</p>
<p><strong>STATIC VS. DYNAMIC</strong></p>
<p>If you are already thinking that you need to move from the &#8216;static&#8217; html world to the &#8216;dynamic&#8217; one, you probably already know why.  If not, let&#8217;s take two minutes to explain why you would want to do this:</p>
<p><strong>Static Sites</strong></p>
<p>While regular HTML pages are awesome all on their own, there are a few limitations to them:</p>
<ul>
<li><strong>They&#8217;re Static</strong> &#8211; Meaning that whatever content you put into them, that&#8217;s exactly the way they&#8217;ll stay.  All content will remain exactly the same way until the next time you edit the page and re-upload it.</li>
<li><strong>Lots and Lots o&#8217; Pages</strong> &#8211; A typical website will probably have anywhere from 30 to 300 individual &#8216;pages&#8217; if you start counting every single internal link&#8230; that&#8217;s a whole lot to keep track of!  Keep in mind that for the most part, most pages probably share the exact same layout too (this here is what we call fore-shadowing *wink wink*)!</li>
<li><strong>Lots and Lots o&#8217; Maintenance Time</strong> &#8211; Time is money, or so they say&#8230; but even if you are not doing the web thing for money, time is well, time!  Maintaining a site with a large amount of pages can be very costly from a time-perspective, and can be very frustrating especially with changes to elements or blocks of text that are shared across site pages (there goes your weekend)!</li>
</ul>
<p><strong>Dynamic Sites</strong></p>
<p>&#8220;So what&#8217;s the alternative&#8221; you ask? Great question!  Dynamic Sites help solve these limitations for us&#8230; here&#8217;s how:</p>
<ul>
<li><strong>They&#8217;re Dynamic</strong> &#8211; &#8220;Yes, you&#8217;ve mentioned that&#8230; what does that mean?&#8221; Dynamic sites are generally designed with only a few page layouts, which are reused over and over, where the actual content comes from a database or other &#8216;dynamic source&#8217;, meaning that instead of changing a page or sets of pages, you simply change the data, and the page(s) instantly change to display the content!</li>
<li><strong>Lots o&#8217; Pages Be Gone</strong> &#8211; Now, because we are reusing most of the page layouts mentioned, this means that even a website with 300, 500, 1000+ pages, could literally be made up of two or three actual &#8216;HTML&#8217; (or in our case, PHP) pages!  How&#8217;s that for working smarter and not harder?</li>
<li><strong>Maintenance Time? Sure I&#8217;ve Got a Sec</strong> &#8211; Maintenance? Oh yeah, that&#8217;s what you do now during commercial breaks&#8230; Imagine making one change on your page layout and have it immediately &#8216;update&#8217; across your 3000-page site?  I exaggerate you say?!?!  Bite your tongue!</li>
</ul>
<p>Now, if you still need any further convincing, consider this: <strong>MOST</strong> if not <strong>ALL</strong> of the major blogging and CMS platforms out there like <strong>WordPress</strong>, <strong>MovableType</strong>, <strong>Drupal</strong>, <strong>Joomla</strong> and many others are based completely on PHP and MySQL!  If you have ever worked with or even seen the sites built around any of these platforms then you can imagine how powerful these dynamic websites are.  Think of the endless development possibilities you&#8217;ll have once you understand how to create websites using these two amazing components.</p>
<p><strong>OKAY, I&#8217;M SOLD!</strong></p>
<p>Glad to hear it!  Now, if you are starting to feel a little overwhelmed at this point, <strong>don&#8217;t!</strong> While the thought of taking a peek behind all the gears and levers that make up the &#8216;belly of the beast&#8217; of such things like the WordPresses and Drupals of the web world may feel a bit daunting, rest assured&#8230; we&#8217;ll be taking the behind the scenes tour nice and slow.</p>
<p>After all, no one can be expected to run before they learn how to crawl, therefore crawl we shall!  And before you know it, you&#8217;ll be copyrighting, patenting and putting the final touches on your very own, next-generation monolith of a web-blogging-cms-type-gigantor-dynamic-content-chewing-snarling-creature of a platform, sure to inspire fear and awe in the hearts of future, fledgling newbee HTML dabblers, staring blankly in amazement at the wonder that is: <strong>YOUR DYNAMIC WEB CREATION</strong>!!! (enter ominous three-note flourish here).**<br />
**results may vary.</p>
<p><strong>THE CRAWL</strong></p>
<p>Okay, still with me?  Awesome!  As promised, we will take this journey nice and slow. And while I know that you are just dying to jump right in, we need to go over some basic concepts in order to bring you up to speed with what you&#8217;ll be working with (if it helps the attention span at all, think of yourself as a pilot standing on the tarmac about to get a crash-course on the inner-working of his/her shiny new jet fighter&#8230; planes make everything funner don&#8217;t they?).</p>
<p><strong>PHP</strong></p>
<p>Let&#8217;s start by talking about PHP.  For the sake of trivial knowledge (and in case you ever want to impress your geeky friends), back in the day, &#8216;PHP&#8217; originally stood for <strong>Personal Home Page</strong>, and was used for that specific reason&#8230; a web page where mom and pop could post pictures of the family, pets, etc., in other words, non-business related web pages.</p>
<p>Today, however, &#8216;PHP&#8217; stands for <strong>Hypertext Preprocessor</strong>; doesn&#8217;t make much sense does it?  Don&#8217;t spend too much time pondering that&#8230; it was actually born of geeky &#8216;recursive acronym&#8217; humor.  If you don&#8217;t find it amusing, good for you&#8230; that just means your inner-geek has not completely taken over just yet.</p>
<p>I&#8217;ve found that the easiest way to grasp what PHP actually does is like this:</p>
<p><strong>FOR THE MATH FANS</strong></p>
<p>Think of HTML as basic arithmetic formula:</p>
<p><code><strong>1 + 2 = 3</strong></code></p>
<p>Where the left side (<strong>1 + 2</strong>) is your (HTML) code and the right side (<strong>3</strong>) is what you see in a browser (the result).  The formula is all laid out for you, all the parts are visible, and just like HTML, it&#8217;s static.  If you wanted to change the result of the formula (or what you see as a result), you have to change the original equation:</p>
<p><code><strong>2 + 2 = 4</strong></code></p>
<p>We are able to change the result, but only after we&#8217;ve made some visible changes to that first part.  Following me so far?</p>
<p>PHP on the other hand, is more like an algebraic formula (if you&#8217;re not good at math, don&#8217;t worry, it&#8217;s just a concept):</p>
<p><code><strong>x + 2 = y</strong></code></p>
<p>Where the left side (<strong>x + 2</strong>) is your (PHP) code and the right side (<strong>y</strong>) is, again, what you seen in a browser (the result).  The difference here is that instead of dealing with static &#8216;input&#8217; giving static &#8216;output&#8217;, we are working with <strong>variables</strong>, meaning that we can <strong>substitute </strong>any value (or content) on the left side (the code) and generate a different result as output (or what you&#8217;ll see in a browser), therefore if we were to use:</p>
<p><code><strong>x = 1</strong></code><br />
we&#8217;d get:<br />
<code><strong>x</strong> + 2 = <strong>3</strong></code></p>
<p>while:</p>
<p><code><strong>x = 2</strong></code><br />
would give:<br />
<code><strong>x</strong> + 2 = <strong>4</strong></code></p>
<p>What this means is that PHP allows you to use <strong>variables</strong> instead of <strong>static values</strong>. By assigning a value (text or numeric) to a variable, PHP will display or calculate content based on the assigned value!</p>
<p>&#8220;That makes no sense&#8221; you say? Let&#8217;s approach it in a slightly different way:</p>
<p><strong>FOR THE REST OF US</strong></p>
<p>Okay, so the math thing is tripping you up&#8230; no worries,  let&#8217;s try a non-mathematical, real-world example instead:</p>
<p>Let&#8217;s say you&#8217;re working on a page for <strong>Gloopy Goop Mfg Co. </strong>on which you want to showcase the &#8216;<strong>Goop of the Month Product</strong>&#8216; on several different spots. Now, being the smart, funny, charming and extremely clever dynamic web developer that you are,  you want to make your life easier by not having to hunt down and change every showcase item reference on the page next month, when the &#8216;Goop of the Month Product&#8217; changes.</p>
<p>Rather than doing what you would normally do in plain old HTML, which would be having this in January:</p>
<blockquote><p>&#8220;Gloopy Goop Proudly presents: <strong>Glooptastic Goop Application Gel</strong>!  Buy your very own <strong>Glooptastic Goop Application Gel </strong>today!&#8221;</p></blockquote>
<p>Then in February, changing each instance manually to:</p>
<blockquote><p>&#8220;Gloopy Goop Proudly presents: <strong>Glooptastic Goop Remover</strong>!  Buy your very own <strong>Glooptastic Goop Remover </strong>today!&#8221;</p></blockquote>
<p>PHP allows you to set up some variables ahead of time like this:</p>
<p><code><strong>$MonthlyItem = "Glooptastic Goop Application Gel";</strong></code></p>
<p>Then set up your wording like this:</p>
<p><code>"Gloopy Goop Proudly presents: <strong>$MonthlyItem</strong>! Buy your very own <strong>$MonthlyItem</strong> today!"</code></p>
<p>So that the resulting output looks like this:</p>
<blockquote><p>&#8220;Gloopy Goop Proudly presents: <strong>Glooptastic Goop Application Gel</strong>! Buy your very own <strong>Glooptastic Goop Application Gel </strong>today!&#8221;</p></blockquote>
<p>Then, in February, by simply changing that original variable to:</p>
<p><code><strong>$MonthlyItem = "Glooptastic Goop Remover";</strong></code></p>
<p>Every instance of that variable throughout the page changes accordingly, like so:</p>
<blockquote><p>&#8220;Gloopy Goop Proudly presents: <strong>Glooptastic Goop Remover</strong>! Buy your very own <strong>Glooptastic Goop Remover </strong>today!&#8221;</p></blockquote>
<p>Makes more sense doesn&#8217;t it?</p>
<p><strong>DAY 1 WRAP UP</strong></p>
<p>Okay!  We are going to stop right there for today and let that concept sink in properly.  In <strong>Day 2</strong>, we will take a closer look at PHP and start getting our hands dirty with some actual <strong>working examples</strong>!  For you over-acheivers out there who feel more comfortable coming prepared to class, feel free to go to one of these two links (depending on whether you are a Mac or a PC) and download a copy of either <strong>MAMP</strong> (for Mac) or <strong>WAMP</strong> (for PC); both are absolutely free and will be needed if you want to follow along with the rest of us:</p>
<p><strong>MAMP</strong> (for Mac) &#8211; <a href="http://www.mamp.info" target="_blank">http://www.mamp.info</a> (standard MAMP is fine)</p>
<p><strong>WAMP</strong> (for PC) &#8211; <a href="http://www.wampserver.com/en/download.php" target="_blank">http://www.wampserver.com/en/download.php</a></p>
<p>After you&#8217;ve downloaded the version that&#8217;s right for you, go ahead and install it.  Feel free to keep all the defaults as you move through the installer, the standard settings should work just fine for most.</p>
<p>After that, come back tomorrow and we&#8217;ll get started on some real, hands-on dynamic webbing!  See you all back here for <strong><a href="/2010/05/day-2-getting-started-with-dynamic-web-development-php-mysql-–-prep-time/">DAY 2 &#8211; Prep Time</a></strong>!</p>
<p><a href="http://www.melikeweb.com/2010/05/day-1-gettings-started-with-dynamic-web-development-php-mysql-introduction/#respond" title="Comment on Day 1: Getting Started with Dynamic Web Development (PHP &amp; MySQL) &#8211; Introduction">Leave a Comment</a></p>]]></content:encoded>
									<wfw:commentRss>http://www.melikeweb.com/2010/05/day-1-gettings-started-with-dynamic-web-development-php-mysql-introduction/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
								</item>			
    	
	</channel>
</rss>

