<?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>JavaScript Workshop &#187; PHP</title>
	<atom:link href="http://www.javascriptworkshop.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javascriptworkshop.com</link>
	<description>Helping others learn JavaScript and web development in general.</description>
	<lastBuildDate>Tue, 06 Sep 2011 11:10:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>PHP Style Switcher</title>
		<link>http://www.javascriptworkshop.com/2009/02/12/php-style-switcher/</link>
		<comments>http://www.javascriptworkshop.com/2009/02/12/php-style-switcher/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 05:00:45 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP Style Switcher]]></category>
		<category><![CDATA[Style Switcher]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=247</guid>
		<description><![CDATA[A while ago, I wrote a post on how to create a JavaScript Style Switcher, but recently I found the need to create a PHP based one. There are many ways to do this in PHP using sessions, arrays, cookies, etc. I created one that only takes a few lines of code and is super [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I wrote a post on how to create a <a href="http://www.javascriptworkshop.com/2007/06/16/june-meeting-javascript-style-switcher/">JavaScript Style Switcher</a>, but recently I found the need to create a PHP based one. There are many ways to do this in PHP using sessions, arrays, cookies, etc. I created one that only takes a few lines of code and is super easy to implement.</p>
<p>This <a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/php_css_switcher/index.php">PHP Style Switcher</a> can be done in two easy steps.</p>
<p><strong>Step One: Setting styles</strong></p>
<p>The first step is to create a new file on your server named <strong>switcher.php</strong> and paste the following code into it:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/* expire in 1 year */</span>
<span style="color: #990000;">setcookie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sitestyle&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'set'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">31536000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: <span style="color: #006699; font-weight: bold;">$HTTP_REFERER</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>When it&#8217;s queried, this file will write a cookie for the user detailing which site style to use. The cookie is set to expire in one year, and then the script sends the user back to the referring page. All of this happens behind the scenes, so the user will never really &#8220;see&#8221; switcher.php in action. </p>
<p>Telling switcher.php which site style to use is an equally simple matter. You can query it using conventional HREF links in text, images, or even flash</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;switcher.php?set=red&quot;</span>&gt;</span>change to RED style!<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p><strong>Step Two: Detecting styles</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;User Defined Style&quot;</span><span style="color: #ff0000;">' href=&quot;&lt;?php echo </span>
<span style="color: #009900;">(!$_COOKIE[&quot;sitestyle&quot;]) </span>
<span style="color: #009900;">?'</span>default<span style="color: #ff0000;">':$_COOKIE[&quot;sitestyle&quot;] </span>
<span style="color: #009900;">?&gt;</span></span>.css&quot; /&gt;</pre></div></div>

<p>This tiny script detects which style is in the user’s cookies and prints out the result. If the user doesn’t have cookies enabled, or just hasn’t chosen a site style for themselves yet, the script will default to &#8220;default.css&#8221;. </p>
<p>So there you have it. A cross-browser, backwards-compatible, forwards-compatible, standards-compliant style sheet switcher in just five lines of code. It’s fast, straightforward, and universally accessible because there’s no processing done on the client side.</p>
<p>Here is the <a href="http://www.javascriptworkshop.com/PHPWebHost/php_css_switcher/php_css_switcher.zip" >code</a> (.zip) as well for you to review.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2009/02/12/php-style-switcher/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP Pagination</title>
		<link>http://www.javascriptworkshop.com/2007/11/05/php-pagination/</link>
		<comments>http://www.javascriptworkshop.com/2007/11/05/php-pagination/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 12:38:24 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Pagination]]></category>
		<category><![CDATA[video tutorials]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=116</guid>
		<description><![CDATA[The technique of splitting up a information into multiple pages is known as pagination. For web pages it normally means taking a resultset from a database query and only showing a specific number of records per page. There are many variations of how to do this no matter what technology (PHP, ASP, JSP, Coldfusion) you [...]]]></description>
			<content:encoded><![CDATA[<p>The technique of splitting up a information into multiple pages is known as <a class = "externalLink" href = "http://en.wikipedia.org/wiki/Pagination">pagination</a>.  For web pages it normally means taking a resultset from a database query and only showing a specific number of records per page. There are many variations of how to do this no matter what technology (PHP, ASP, JSP, Coldfusion) you use.  </p>
<p><span id="more-116"></span></p>
<p>Jonathan Sampson created a very useful <a href="http://www.javascriptworkshop.com/wp-content/uploads/zip/PHP/PHP_Pagination.zip">screencast</a> (.zip) showing you exactly how to do this using PHP and MySQL.  I took his <a href = "http://www.javascriptworkshop.com/PHPWebHost/php_pagination/pagination.zip">code</a> (.zip) and created my <a class = "externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/php_pagination/pagination.php">own simple example</a>.</p>
<p>Looking over the code and demo you will see it is a fairly complete solution for any type of data that you may need pagination.  Since it is so complete you probably will need a little time to fully understand it (like me), but Jonathan explains it very nicely in the video.<br />
<br/></p>
<p><strong>1. Grab the total number of database records and pages:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get total number of database entries</span>
<span style="color: #000088;">$totalCount</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT COUNT(*) as 'Total' FROM pagination&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rsCount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$totalCount</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span>
<span style="color: #000088;">$rowCount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rsCount</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get our total number of pages</span>
<span style="color: #000088;">$numOfPages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rowCount</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Total</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$perPage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>2. Creating paging links for next and prev as well as each page:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// If our current page, minus our padding, is greater than 1</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$padding</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;... &quot;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Set our lower limit</span>
     <span style="color: #000088;">$lowerLimit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$padding</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Print all padded numbers between lowerLimit and current</span>
     <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lowerLimit</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$pageNumber</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>page.php?page=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Print all numbers between current page, and first page</span>
     <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$pageNumber</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
           <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>page.php?page=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// If not on first page, or last page, print current page</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$numOfPages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;b&gt; - &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; - &lt;/b&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// If current page, plus padding, is less than the total pages</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$padding</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$numOfPages</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Set upper limit</span>
     <span style="color: #000088;">$upperLimit</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$padding</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Print all number from padded pages above current page</span>
     <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$upperLimit</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>page.php?page=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;... &quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Print numbers between number of pages and current page</span>
     <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageNumber</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$numOfPages</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>page.php?page=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt; &quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>3. Grab the page results and display them:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get page results</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT id, teams FROM pagination ORDER BY id
        LIMIT <span style="color: #006699; font-weight: bold;">$startIndex</span>, <span style="color: #006699; font-weight: bold;">$perPage</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get result set</span>
<span style="color: #000088;">$rs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Do we have results?</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rs</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Show the results</span>
     <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rs</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
          <span style="color: #b1b100;">print</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">print</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">teams</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Sorry, no results found.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2007/11/05/php-pagination/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Web Site &#8211; Using New PHP 5 Features</title>
		<link>http://www.javascriptworkshop.com/2006/12/13/php-web-site-using-new-php-5-features/</link>
		<comments>http://www.javascriptworkshop.com/2006/12/13/php-web-site-using-new-php-5-features/#comments</comments>
		<pubDate>Wed, 13 Dec 2006 09:39:00 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[video tutorials]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=88</guid>
		<description><![CDATA[In my attempt to learn PHP I thought I would create a simple web site that does some basic database interaction (select, insert, update and delete), sorting and paging, keyword search, and use some of the new PHP 5 features such as OOP, exception handling and the new mysqli extension for MySQL 4.1 and above. [...]]]></description>
			<content:encoded><![CDATA[<p>In my attempt to learn PHP I thought I would create a simple web site that does some basic database interaction (select, insert, update and delete), sorting and paging, keyword search, and use some of the new PHP 5 features such as OOP, exception handling and the new mysqli extension for MySQL 4.1 and above.</p>
<p><span id="more-88"></span></p>
<p>The <a class="externalLink" href="http://www.javascriptworkshop.com/PHPWebHost/php_site/index.php">web site</a> has some features that I&#8217;ve seen elsewhere on the web such as paging, sorting data and keyword search highlighting.  The hard part was finding the resources to explain how to do these techniques because no book gives you all the answers.</p>
<p>The new PHP 5 features I implemented can be found in any current PHP book.  The <a class="externalLink" href="http://en.wikipedia.org/wiki/Object-oriented_programming">OOP</a>  techniques added has the advantages such as increased code reuse, modularity and flexiblity for expansion. This style of coding has been around for a long time (like exception handling) so it was a nice addition in my opinion to PHP 5.</p>
<p>Though for a web site this small using OOP may not be necessary, but will give you a good example of basic syntax and basic implementation. Here are some screencasts  (.zip) by Jonathan Sampson that explain PHP OOP development with the <a href="http://www.javascriptworkshop.com/wp-content/uploads/zip/PHP/PHP_OOP1_Video.zip">first video</a> covering what is a class and how to create one and the <a href="http://www.javascriptworkshop.com/wp-content/uploads/zip/PHP/PHP_OOP2_Video.zip">second video</a> showing you how to create private, public and protected properties within a class.  The <a href="http://www.javascriptworkshop.com/wp-content/uploads/zip/PHP/PHP_OOP3_Video.zip">third video</a> covers interfaces and abstractions that are not used.</p>
<p>Other new PHP 5 features I used were <a class="externalLink" href="http://us3.php.net/manual/en/language.exceptions.php">exceptions</a>, which are a new way of handling errors in your PHP code.  As with OOP, this feature has been around in other programming languages (VB.NET, C#, Java, etc.), and in my opinion a easier and better way to capture unexpected errors (i.e. database error).  The last new feature was using the <a class="externalLink" href="http://us3.php.net/manual/en/ref.mysqli.php">mysqli extension</a> which incorporates new functionality in MySQL 4.1 and above.  The changes are small (compared to mysql extension) and very easy to implement in any exisiting PHP code you may have.</p>
<p>I also used functions such as <a class="externalLink" href="http://us3.php.net/manual/en/mysqli.real-escape-string.php">mysqli_real_escape_string</a> and <a class="externalLink" href="http://us3.php.net/manual/en/function.addslashes.php">addslashes</a> to help prevent against <a class="externalLink" href="http://en.wikipedia.org/wiki/SQL_injection_attack">SQL injection</a>. </p>
<p>There are many other issues of security that should be considered when developing web applications. Read the <a class = "externalLink" href = "http://www.javascriptworkshop.com/wp-content/uploads/pdf/php-security-guide.pdf">PHP Security Guide</a> (.pdf) by the people at the <a class="externalLink" href = "http://phpsec.org/projects/">PHP Security Consortium</a> to learm more.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/12/13/php-web-site-using-new-php-5-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP vs. ASP.NET</title>
		<link>http://www.javascriptworkshop.com/2006/09/29/php-vs-aspnet-articles/</link>
		<comments>http://www.javascriptworkshop.com/2006/09/29/php-vs-aspnet-articles/#comments</comments>
		<pubDate>Fri, 29 Sep 2006 00:23:47 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=70</guid>
		<description><![CDATA[Sean Hull wrote two great articles describing the differences between the latest versions of PHP (ver 5) and ASP.NET (ver 2.0).  The first article gave a good introduction to both technologies, while the second article went into more detail of advanced features such as OOP in PHP and the .NET framework in ASP.NET.]]></description>
			<content:encoded><![CDATA[<p>Sean Hull wrote two great articles describing the differences between the latest versions of PHP (ver 5) and ASP.NET (ver 2.0).  The <a class="externalLink" href="http://www.javascriptworkshop.com/wp-content/uploads/web/PHP%20vs_%20ASP_NET.htm">first article</a> gave a good introduction to both technologies, while the <a class="externalLink" href="http://www.javascriptworkshop.com/wp-content/uploads/web/PHP%20vs_%20ASP_NET%20Redux.htm">second article</a> went into more detail of advanced features such as OOP in PHP and the .NET framework in ASP.NET.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/09/29/php-vs-aspnet-articles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring IIS and Apache for PHP</title>
		<link>http://www.javascriptworkshop.com/2006/03/26/configuring-iis-and-apache-for-php/</link>
		<comments>http://www.javascriptworkshop.com/2006/03/26/configuring-iis-and-apache-for-php/#comments</comments>
		<pubDate>Sun, 26 Mar 2006 00:27:32 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Installation]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=120</guid>
		<description><![CDATA[As I mentioned in a previous post, in order to develop PHP web pages on your local PC you need a web server installed. You basically have two choices: Use a software package to install everything you need or you can install them separately to get the greatest control over your development environment. For Windows [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in a <a href = "http://www.javascriptworkshop.com/2005/11/03/setting-up-a-php-mysql-development-environment/">previous post</a>, in order to develop PHP web pages on your local PC you need a web server installed. You basically have two choices: Use a software package to install everything you need or you can install them separately to get the greatest control over your development environment. For Windows users if you do not have the Professional edition that includes Internet Information Server (IIS) you need to down the Apache web server instead.  </p>
<p>Configuring either IIS or Apache can be tricky and somewhat confusing so I did the research for you and give you detailed steps on how to configure either IIS or Apache to work with PHP.</p>
<p><span id="more-120"></span></p>
<p><strong>Setting up PHP</strong> (for IIS or Apache)</p>
<p>1. <a class = "externalLink" href = "http://www.php.net/downloads.php">Download</a> the latest Windows zip package<br />
2. Extract the files to c:\PHP (PHP folder)<br />
3. Find libmysql.dll and php5ts.dll and copy to c:\windows\system32<br />
4. In PHP folder: find php.ini-dst and make a copy<br />
5. Rename the copy to php.ini<br />
6. Move the php.ini to c:\Windows<br />
7. Open the file in Notepad<br />
8. Find extension_dir = &#8220;./&#8221; and change to extension_dir = &#8220;c:\PHP\ext&#8221;<br />
9. Find ;extension=php_mysql.dll and remove semi-colon<br />
10. Find ;extension=php_mysqli.dll and remove semi-colon<br />
11. Create a temp directory (c:\temp)<br />
12. Find ;session.save_path and change to session.save_path = &#8220;c:\temp&#8221;<br />
13. Save and close Notepad</p>
<p><strong>Configuring IIS</strong></p>
<p>1. Control Panel -> Administrative Tools -> Internet Information Service<br />
2. Right click on Default Web Site -> Properties<br />
3. ISAPI Filters tab: Add PHP filter with executable c:\PHP\php5isapi.dll<br />
4. Home Directory tab:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Click Configuration, Click Add (Mappings tab)<br />
&nbsp;&nbsp;&nbsp;&nbsp;Executable: c:\PHP\php5isapi.dll and Extension: .php<br />
&nbsp;&nbsp;&nbsp;&nbsp;Click OK<br />
&nbsp;&nbsp;&nbsp;&nbsp;Now all .php files will be processed using the PHP library (php5isapi.dll)<br />
5. Documents tab:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Click Add<br />
&nbsp;&nbsp;&nbsp;&nbsp;Default Document Name: index.php<br />
6.  Restart IIS<br />
&nbsp;&nbsp;&nbsp;&nbsp;Go to Services (Administrative Tools -> Services)<br />
&nbsp;&nbsp;&nbsp;&nbsp;Select World Wide Web Publishing Service<br />
&nbsp;&nbsp;&nbsp;&nbsp;Click Restart the service button</p>
<p><strong>Configuring Apache</strong></p>
<p>1. <a class = "externalLink" href = "http://httpd.apache.org/download.cgi">Download</a> the Win32 binary (MSI Installer)<br />
2. Run the installer wizard<br />
&nbsp;&nbsp;&nbsp;&nbsp;During install enter &#8220;localhost&#8221; for Network Domain and Server Name<br />
3. Program Files -> Apache HTTP Server -> Configure Apache Server<br />
&nbsp;&nbsp;&nbsp;&nbsp;Edit Apache httpd.conf file<br />
4. Find LoadModule<br />
&nbsp;&nbsp;&nbsp;&nbsp;Go to the bottom of section and add a new line:<br />
&nbsp;&nbsp;&nbsp;&nbsp;LoadModule php5_module c:/php/php5apache2.dll<br />
5. Find DirectoryIndex<br />
&nbsp;&nbsp;&nbsp;&nbsp;Add to exisiting line:<br />
&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex index.html index.html.var<br />
&nbsp;&nbsp;&nbsp;&nbsp;DirectoryIndex index.html index.html.var index.php<br />
6. Find AddType<br />
&nbsp;&nbsp;&nbsp;&nbsp;Add a new line to the bottom of this section:<br />
&nbsp;&nbsp;&nbsp;&nbsp;AddType application/x-httpd-php .php<br />
7. Save and close Notepad<br />
8. Restart Apache:<br />
&nbsp;&nbsp;&nbsp;&nbsp;Program Files -> Apache HTTP Server -> Control apache Server -> Restart</p>
<p><strong>Testing PHP</strong></p>
<p>1. Create an index.php file with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
       <span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>2. Save to:<br />
&nbsp;&nbsp;&nbsp;&nbsp;c:\inetpub\wwwroot (IIS)<br />
&nbsp;&nbsp;&nbsp;&nbsp;c:\Program Files\Apache Group\Apache2\htdocs (Apache)<br />
3.  Type http://localhost/ and it should look something like <a class = "externalLink" href = "http://www.javascriptworkshop.com/PHPWebHost/php_test/index.php">this</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/03/26/configuring-iis-and-apache-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL and phpMyAdmin Tutorial Videos</title>
		<link>http://www.javascriptworkshop.com/2006/02/07/mysqlphp-video/</link>
		<comments>http://www.javascriptworkshop.com/2006/02/07/mysqlphp-video/#comments</comments>
		<pubDate>Tue, 07 Feb 2006 18:09:21 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Video tutorials]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[video tutorials]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=71</guid>
		<description><![CDATA[Once you learn the basics of PHP, you will want to know how to interact with a database and update its data from a web page. MySQL is the most obvious and recommended choice using PHP and is fairly easy to setup. You can use phpMyAdmin to easiy setup your MySQL database, tables and perform [...]]]></description>
			<content:encoded><![CDATA[<p>Once you learn the <a href="http://www.javascriptworkshop.com/2005/10/30/php-basics-video-tutorials/">basics of PHP</a>, you will want to know how to interact with a database and update its data from a web page. <a class="externalLink" href = "http://www.mysql.com/">MySQL</a> is the most obvious and recommended choice using PHP and is fairly easy <a href="http://www.javascriptworkshop.com/2005/11/03/tools-for-a-local-php-mysql-environment/">to setup</a>.</p>
<p>You can use <a class = "externalLink" href="http://www.phpmyadmin.net/home_page/index.php">phpMyAdmin</a> to easiy setup your MySQL database, tables and perform any necessary SQL statements.</p>
<p><span id="more-71"></span></p>
<p>Here are some videos (.zip) to get you started:</p>
<p><a href="/wp-content/uploads/zip/PHP/mySQL_Intro.zip">MySQL Overview</a><br />
<a href="/wp-content/uploads/zip/PHP/mySQL_basics.zip">MySQL Basics</a><br />
<a href="/wp-content/uploads/zip/PHP/mySQL_SQL.zip">SQL Statements with MySQL</a><br />
<a href="/wp-content/uploads/zip/PHP/mySQL_phpmyadmin.zip">Using PHPMyAdmin</a><br />
<a href="/wp-content/uploads/zip/PHP/php_withmySQL.zip">PHP and SQL</a><br />
<a href="/wp-content/uploads/zip/PHP/php_withmySQL_cont.zip">PHP and SQL cont.</a></p>
<p>Here is a <a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_MYSQL.pdf">great article</a> (.pdf) reviewing most of what is covered in the videos as well written by Gareth Downes-Powell.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2006/02/07/mysqlphp-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tools for a Local PHP/MySQL Environment</title>
		<link>http://www.javascriptworkshop.com/2005/11/03/tools-for-a-local-php-mysql-environment/</link>
		<comments>http://www.javascriptworkshop.com/2005/11/03/tools-for-a-local-php-mysql-environment/#comments</comments>
		<pubDate>Thu, 03 Nov 2005 00:25:01 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Free Editors]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.javascriptworkshop.com/?p=83</guid>
		<description><![CDATA[In order to setup a proper development environment for your home PC to create and test PHP and MySQL web pages you will need at least three components: Web server: PHP will work with virtually all web server software, including Microsoft&#8217;s Internet Information Server (IIS), but is most often used with the freely available Apache server. [...]]]></description>
			<content:encoded><![CDATA[<p>In order to setup a proper development environment for your home PC to create and test PHP and MySQL web pages you will need at least three components:</p>
<p><span id="more-83"></span></p>
<p><strong>Web server:</strong> PHP will work with virtually all web server software, including Microsoft&#8217;s Internet Information Server (IIS), but is most often used with the freely available <a class="externalLink" href="http://httpd.apache.org/">Apache server</a>.</p>
<p><strong>Database:</strong> PHP will work with virtually all database software, including ORACLE and Sybase, but is most often used with free <a class="externalLink" href="http://dev.mysql.com/downloads/">MySQL database</a> software for which it has specific optimizations.</p>
<p><strong>PHP parser:</strong> In order to process PHP script instructions, a <a class="externalLink" href="http://www.php.net/downloads.php">parser</a> must be installed to generate HTML output that can be sent to the web browser.  The parser engine is identical, irrespective of the operating system, so PHP pages need no changes to run on different platforms.</p>
<p><strong>Editors:</strong> You can use a free web editor to make writing and editing PHP scripts easier such as <a class = "externalLink" href="http://www.download.com/PHP-Designer-2007-Personal/3000-10248_4-10575026.html?cdlPid=10592128">PHP Designer 2007 &#8211; Personal</a> or <a class = "externalLink" href="http://activestate.com/Products/komodo_ide/komodo_edit.mhtml">Komodo Edit</a> which have features such as code highlighting, autocomplete and debugging.</p>
<p>Each of these components can be installed seperately, but would require configuration changes for them to work properly.</p>
<p>An easier solution would be to <strong>install a software package</strong> that does everything for you. The most popular are <a class="externalLink" href="http://www.apachefriends.org/en/xampp.html">XAMPP</a>, <a class="externalLink" href="http://www.wampserver.com/en/">WAMP5</a>, and <a class = "externalLink" href = "http://www.uniformserver.com/">Uniform Server</a>.  These distributions make it easy to get started developing in PHP and MySQL without all the extra hassle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2005/11/03/tools-for-a-local-php-mysql-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Basics &#8211; Video Tutorials</title>
		<link>http://www.javascriptworkshop.com/2005/10/30/php-basics-video-tutorials/</link>
		<comments>http://www.javascriptworkshop.com/2005/10/30/php-basics-video-tutorials/#comments</comments>
		<pubDate>Sun, 30 Oct 2005 19:56:19 +0000</pubDate>
		<dc:creator>Frank Stepanski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Video tutorials]]></category>

		<guid isPermaLink="false">http://wordpress.stepanskiconsulting.com/?p=14</guid>
		<description><![CDATA[Only recently have I started to learn PHP and am starting to realize what all the fuss is about. PHP has been around for 10 years and has gained steady increasing popularity. It is fast, fairly easy to learn, integrates with many database systems (MySQL, SQL Server, ORACLE), used on all major operating systems, and [...]]]></description>
			<content:encoded><![CDATA[<p>Only recently have I started to learn PHP and am starting to realize what all the fuss is about. PHP has been around for 10 years and has gained steady increasing <a class="externalLink" href="http://www.php.net/usage.php">popularity</a>.</p>
<p><span id="more-14"></span></p>
<p>It is fast, fairly easy to learn, integrates with many database systems (MySQL, SQL Server, ORACLE), used on all major operating systems, and is open source which means there are many add-on components to use (i.e. PEAR) that extend its functionality. It costs nothing to <a class="externalLink" href="http://www.php.net/downloads.php">download</a> and all you need is a web server, whether it be open-source (Apache) or Internet Information Server.</p>
<p><img src = "http://www.javascriptworkshop.com/PHP_Works.gif" /></p>
<p><strong>Video Tutorials:</strong></p>
<p><a href="/wp-content/uploads/zip/PHP/PHP_First_script.zip">Your First Script</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Variables.zip">Variables</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Strings.zip">Strings</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_String_functions.zip">String Functions</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Numbers.zip">Numbers</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Arrays.zip">Arrays</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_IF_else.zip">Conditional Statement: IF Else</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Switch.zip">Conditional Statement: Switch</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Creating_functions.zip">User-Defined Functions: Creating</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Using_functions.zip">User-Defined Functions: Using</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_ReturnValues_Functions.zip">User-Defined Functions: Return Values</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_Global_variable.zip">Global Variables and Functions</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_For_loop.zip">For Loops</a><br />
<a href="/wp-content/uploads/zip/PHP/PHP_While_loop.zip">While Loops</a></p>
<p>Here are also some great articles (.pdf) written by Gareth Downes-Powell covering the same and some new topics:</p>
<p><a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_Basics.pdf">Basics </a><br />
<a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_Arrays.pdf">Arrays</a><br />
<a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_String_Functions.pdf">String Functions</a><br />
<a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_ConditionalStatements.pdf">Conditional Statements</a><br />
<a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_Functions.pdf">Functions</a><br />
<a class="externalLink" href="/wp-content/uploads/pdf/PHP/PHP_Working_Forms.pdf">Working with Forms</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.javascriptworkshop.com/2005/10/30/php-basics-video-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

