<?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>onDeveloping &#187; php</title>
	<atom:link href="http://zbrustudios.com/onDeveloping/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://zbrustudios.com/onDeveloping</link>
	<description>thoughts on developing from zach mccorkhill @ z.bru studios</description>
	<lastBuildDate>Thu, 18 Nov 2010 22:02:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>on PHP and MySQL</title>
		<link>http://zbrustudios.com/onDeveloping/2009/06/on-php-and-mysql/</link>
		<comments>http://zbrustudios.com/onDeveloping/2009/06/on-php-and-mysql/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 15:57:54 +0000</pubDate>
		<dc:creator>zach</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zbrustudios.com/onDeveloping/?p=81</guid>
		<description><![CDATA[Wow. So I&#8217;m a little embarassed even writing this, but until recently I hadn&#8217;t really worked with MySQL. Sure, I&#8217;m using WordPress for this blog, and I&#8217;ve used Joomla! and Drupal, but I&#8217;ve never rolled up my sleaves and worked on programming PHP to create MySQL tables and retrieving data. Wow. What I have been [...]]]></description>
			<content:encoded><![CDATA[<p>Wow. So I&#8217;m a little embarassed even writing this, but until recently I hadn&#8217;t really worked with MySQL. Sure, I&#8217;m using WordPress for this blog, and I&#8217;ve used Joomla! and Drupal, but I&#8217;ve never rolled up my sleaves and worked on programming PHP to create MySQL tables and retrieving data. Wow. What I have been missing.</p>
<p>I do a lot of researching and testing different programming languages and internet technoligies, because I love learning new things and I love figuring out the most appropriate and efficient way of doing things. In the past, I&#8217;ve leaned towards using XML as a non-sensitive data holder. What drew me to XML for this purpose was that it was always easy to teach clients how to update and add data to an XML file, and all they needed was a text editor. I had balked at the idea of using MySQL because I assumed it was difficult to learn and use and XML was working just fine for me.</p>
<p>A client of mine has a website where they post a calendar of upcoming events. The events on the calendar also show up on other pages throughout their website. In the past, any time an event was added or the date of an event had passed, I would go into the calendar page and whatever other pages the event was listed on and edit all instances of the event. I&#8217;ve wanted to change this since day one (I &amp;heart; efficiency, remember?), but I&#8217;ve always had a lot of other things on my plate for this client, so i put it off. Oh, how silly of me.</p>
<p>The calendar issue finally came to the front burner for me, and I decided it was time for me to buckle down and learn MySQL. To my surprise it took maybe half an hour to learn the basics of inserting and retrieving data from MySQL using PHP! And with the help of <a href="http://www.phpmyadmin.net/home_page/index.php" target="_blank">phpMyAdmin</a>, managing the data on the client side can be just as easy as using XML. I&#8217;ll post more later with specifics, but this is just a reminder to myself in the future and to anyone else putting off learning efficient and appropriate methods for anything:</p>
<p>STOP. TAKE THE TIME TO SAVE YOURSELF TIME.</p>
]]></content:encoded>
			<wfw:commentRss>http://zbrustudios.com/onDeveloping/2009/06/on-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>on Event Calendar 3 for WordPress</title>
		<link>http://zbrustudios.com/onDeveloping/2009/06/on-event-calendar-3-for-wordpress/</link>
		<comments>http://zbrustudios.com/onDeveloping/2009/06/on-event-calendar-3-for-wordpress/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 06:40:07 +0000</pubDate>
		<dc:creator>zach</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[thoughts]]></category>

		<guid isPermaLink="false">http://zbrustudios.com/onDeveloping/?p=78</guid>
		<description><![CDATA[I&#8217;ve recently been converting a client&#8217;s website over to WordPress. Since I haven&#8217;t spent much time developing my own blog on WordPress (a carpenter&#8217;s house, right?), I thought this would be an excellent opportunity to look into plugins and further customization. One plugin that I found particularly useful for this client was Event Calendar 3. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been converting a client&#8217;s website over to WordPress. Since I haven&#8217;t spent much time developing my own blog on WordPress (a carpenter&#8217;s house, right?), I thought this would be an excellent opportunity to look into plugins and further customization.</p>
<p>One plugin that I found particularly useful for this client was <a href="http://wpcal.firetree.net/" target="_blank">Event Calendar 3</a>. On her previous website, the client had a list of upcoming events and wished to have a similar setup on all pages of her blog. There are several calendar plugins available for WP, and I chose this one for a couple of reasons (and due to some Apache permission problems on her host with some of the other calendar plugins). First of all, it&#8217;s really easy to use and customize. I was able to set up the sidebar to display just the dates and titles of the events. Second, the events are all posts, so there&#8217;s no limitation on what additional information can be posted with the event.</p>
<p>Where I ran into problems with it is that WP treats the posts like any other blog entry. When I click on the category &#8220;Upcoming Events&#8221; it displays all the posts and the date they were posted, not the date the event is happening. Working with the default WP theme, my work around involved editing styles.css and archive.php:</p>
<p>First, I put the date as the first line in the post for all &#8220;Upcoming Events&#8221; posts. After that, there were two dates displayed, the first line was the post date and the second line was the event date. To format the second date to match the first, I grabbed the first paragraph of my post (in category &#8220;Upcoming Events&#8221;) using the first-child pseudo-class:</p>
<pre class="brush: css;">
.category-upcoming-events .entry p:first-child{
color:#666;
}
</pre>
<p>I didn&#8217;t want to get rid of the post date for all categories, so my next step was to change the way archive.php displayed posts with the category &#8220;Upcoming Events.&#8221; In the WP Loop (the section that spits out all the posts), I edited the following section:</p>
<pre class="brush: php;">
&lt;h3 id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;&lt;a title=&quot;Permanent Link to &lt;?php the_title_attribute(); ?&gt;&quot; rel=&quot;bookmark&quot; href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;small&gt;&lt;/small&gt;
</pre>
<p>The part between the &lt;small&gt; tags is the part that displays the time when the post was created. WP has a handy built in boolean function <a href="http://codex.wordpress.org/Template_Tags/in_category" target="_blank">in_category()</a> that returns true if the current post has the category indicated inside the parentheses. A trick I use all the time to save on code and headaches in PHP is using an IF statement and exiting PHP before my &#8216;if true&#8217; statement so as to avoid having to use echo or print, and then going back into PHP and closing the if statement after the HTML, like so:</p>
<pre class="brush: php;">
if(foo == bar){
?&gt;

Hello World!

}
?&gt;
</pre>
<p>Using this style in archive.php, I check the current post to see if it isn&#8217;t in the category &#8220;Upcoming Events,&#8221; and provided it&#8217;s not, I let php go ahead and echo the time the post was created. Otherwise, it just continues without echoing the time. Like so:</p>
<pre class="brush: php;">
&lt;h3 id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;&lt;a title=&quot;Permanent Link to &lt;?php the_title_attribute(); ?&gt;&quot; rel=&quot;bookmark&quot; href=&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;small&gt;&lt;/small&gt;
</pre>
<p>This is all great and dandy, but my next project in this is to display the events in chronological order, in case a last minute event is added to the schedule. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://zbrustudios.com/onDeveloping/2009/06/on-event-calendar-3-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>on PHP includes();</title>
		<link>http://zbrustudios.com/onDeveloping/2008/12/on-php-includes/</link>
		<comments>http://zbrustudios.com/onDeveloping/2008/12/on-php-includes/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 23:46:44 +0000</pubDate>
		<dc:creator>zach</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.zbrustudios.com/onDeveloping/?p=22</guid>
		<description><![CDATA[i love PHP includes. they&#8217;re a big reason why i even use PHP. i was just collaborating on a project that used Dreamweaver templates, which I had never used before. they&#8217;re pretty handy, in their way: i was able to modify a template file and have the changes automatically registered in all the files based [...]]]></description>
			<content:encoded><![CDATA[<p>i love PHP includes. they&#8217;re a big reason why i even use PHP. i was just collaborating on a project that used Dreamweaver templates, which I had never used before. they&#8217;re pretty handy, in their way: i was able to modify a template file and have the changes automatically registered in all the files based off the template (e.g.: i added some javascript to the template, and all the pages were updated with the same javascript while maintaining their individual content). where that gets really unfun, though (and where includes rock the snot off xhtml) is that i had to re-upload every single page in the site when i made changes like that. w/include, i just re-upload the included file.</p>
<p>anyway, i got to thinking about hierarchy with includes b/c a lot of the includes i used for the site were included in different folders and different levels of the site hierarchy. i have a tendancy to put navigation bars in includes for obvious reasons. this can get a little dicey when you move up and down the hierarchy though.</p>
<p>say i&#8217;ve got an include that has my navigation bar, with the first item being a link to the homepage:</p>
<p>&lt;li&gt;&lt;a href=&#8221;index.php&#8221;&gt;Home&lt;/a&gt;&lt;/li&gt;</p>
<p>include this in any file that&#8217;s in the root directory and i&#8217;m fine. but if i move it into another folder (like zbrustudios.com/pictures/) and it would need to be:</p>
<p>&lt;li&gt;&lt;a href=&#8221;../index.php&#8221;&gt;Home&lt;/a&gt;&lt;/li&gt;</p>
<p>when i&#8217;m dealing with large sites, i figured out that this gets all sorts of troublesome when lots of including is done. my simple work around?</p>
<p>in every page i declare a php variable for the depth. so at the root level:</p>
<p>$depth = &#8220;&#8221;;</p>
<p>in a folder (like zbrustudios.com/pictures/):</p>
<p>$depth = &#8220;../&#8221;;</p>
<p>and even deeper (zbrustudios.com/pictures/vacation/):</p>
<p>$depth = &#8220;../../&#8221;;</p>
<p>then in the navigation file that i include on each of these pages the link looks like this:</p>
<p>&lt;li&gt;&lt;a href=&#8221;&lt;?=$depth;?&gt;index.php&#8221;&gt;Home&lt;/a&gt;&lt;/li&gt;</p>
<p>voilà!</p>
]]></content:encoded>
			<wfw:commentRss>http://zbrustudios.com/onDeveloping/2008/12/on-php-includes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>on Forms</title>
		<link>http://zbrustudios.com/onDeveloping/2008/11/on-forms/</link>
		<comments>http://zbrustudios.com/onDeveloping/2008/11/on-forms/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 02:03:43 +0000</pubDate>
		<dc:creator>zach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[html forms]]></category>

		<guid isPermaLink="false">http://www.zbrustudios.com/onDeveloping/?p=7</guid>
		<description><![CDATA[i&#8217;ve been working on some forms for a couple of different clients, and it never ceases to amaze me how much extra time i end up spending on them. i think i finally have my favorite system of validating w/both javascript and php. but i&#8217;m sure that will change. one of the clients was easier [...]]]></description>
			<content:encoded><![CDATA[<p>i&#8217;ve been working on some forms for a couple of different clients, and it never ceases to amaze me how much extra time i end up spending on them. i think i finally have my favorite system of validating w/both javascript and php. but i&#8217;m sure that will change. one of the clients was easier to do in some ways because they only deal with local clients. the other is international, so i had to think about country codes in phone numbers and find a list of every country. in some ways that was easier, though, because validation goes out the window; there are different phone number lengths, some countries don&#8217;t have zip codes, and with a chance of javascript being disabled, there&#8217;s no pretty way of listing different states in different countries. i&#8217;m feeling like someday, since we all deal with forms, form validation/entry will be taken care of by the browser, and the code will just tell the browser what info is wanted (&#8216;address&#8217; instead of &#8216;street address&#8217;, &#8216;state&#8217;, &#8216;zip&#8217;, etc.). api&#8217;s and cms&#8217; are okay for some things, but for a quick and dirty form, it would be nice to have smarter browsers. what a pipe dream though. or maybe a pipe nightmare; i can just imagine having to hack the heck out of css to have the browser &#8216;form&#8217; not explode a site.</p>
]]></content:encoded>
			<wfw:commentRss>http://zbrustudios.com/onDeveloping/2008/11/on-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>on PHP and XML.</title>
		<link>http://zbrustudios.com/onDeveloping/2008/11/on-php-and-xml/</link>
		<comments>http://zbrustudios.com/onDeveloping/2008/11/on-php-and-xml/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 23:24:14 +0000</pubDate>
		<dc:creator>zach</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.zbrustudios.com/onDeveloping/?p=5</guid>
		<description><![CDATA[i’ve been working on a page for a client to have Amazon Associates and iTunes Affiliates links for a number of playlists (each w/100+ songs). i wish there were a pretty way of generating the links directly from the iTunes library file, but alas, i’ve spent many an hour watching tv and looking up the [...]]]></description>
			<content:encoded><![CDATA[<p>i’ve been working on a page for a client to have Amazon Associates and iTunes Affiliates links for a number of playlists (each w/100+ songs). i wish there were a pretty way of generating the links directly from the iTunes library file, but alas, i’ve spent many an hour watching tv and looking up the pertinent information for each song, and building XML pages using some crazy equations in Excel.<br />
there are many things to watch out for when creating XML files, and many as well when parsing an XML file with PHP.  one that i’m getting more and more familiar with is special characters. the ampersand character was one that really gave me pains. the iTunes data had the character &amp;, but XML uses &amp;amp;. to complicate things further, while PHP is parsing XML nodes, if it comes across the ampersand character it splits the data up. for example, i had a tag as follows:<br />
&lt;artist&gt;Huey Lewis &amp; The News&lt;/artist&gt;<br />
on the user end, PHP was only spewing “The News”. i couldn’t figure out a buen solution, try as i might to replace characters while the PHP was building the arrays. today i came across this post:<br />
<a href="“http://www.romej.com/archives/170/xml_parse-and-php-and-ampersands”" target="“_blank”">xml_parse() and php and ampersands</a>.<br />
thank goodness for that! turns out i can concatenate the parts into a lovely whole. check the link for a better explanation, but this is my example:<br />
before:<br />
case $xml_artist_key:<br />
$song_array[$counter]-&gt;artist = $data;<br />
break;</p>
<p>after:<br />
case $xml_artist_key:<br />
$song_array[$counter]-&gt;artist <span style="background-color:#FFFF33">.</span>= $data;<br />
break;<br />
voila!</p>
]]></content:encoded>
			<wfw:commentRss>http://zbrustudios.com/onDeveloping/2008/11/on-php-and-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

