<?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>RedBonzai</title>
	<atom:link href="http://redbonzai.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://redbonzai.com</link>
	<description>Custom Web Application Development for Serious Businesses</description>
	<lastBuildDate>Wed, 03 Oct 2012 15:25:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Free Mobile Applications</title>
		<link>http://redbonzai.com/free-mobile-applications/</link>
		<comments>http://redbonzai.com/free-mobile-applications/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 01:07:32 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[mobile applications]]></category>
		<category><![CDATA[free mobile applications]]></category>

		<guid isPermaLink="false">http://redbonzai.com/?p=1241</guid>
		<description><![CDATA[Do you prefer to be on your mobile device rather than your computer? Here are some free mobile applications that may be useful. We think they&#8217;ll be around for a long time. Reddit Mobile It&#8217;s the same reddit, but mobile. Access reddit.com from the following mobile devices: iPhone/iPod Touch, iPad, Android, webOS, Google Chrome, Safari, [...]]]></description>
			<content:encoded><![CDATA[<p>Do you prefer to be on your mobile device rather than your computer? Here are some <strong>free mobile applications</strong> that may be useful. We think they&#8217;ll be around for a long time.</p>
<table cellspacing="5">
<tbody>
<tr>
<td colspan="2">
<div>
<h3><a href="http://www.reddit.com/static/reddit_mobile/index.htm" rel="nofollow" target="_blank">Reddit Mobile</a></h3>
</div>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1242" title="Reddit Mobile" src="http://redbonzai.com/wp-content/uploads/2012/04/reddit-mobile-150x150.png" alt="" width="150" height="150" /></td>
<td>
<p>It&#8217;s the same reddit, but mobile. Access reddit.com from the following mobile devices: iPhone/iPod Touch, iPad, Android, webOS, Google Chrome, Safari, all other webkit platforms. Reddit mobile is custom UI designed for mobile devices, pure CSS with very few images, fully-featured, and uncluttered.</p>
</td>
</tr>
<tr>
<td colspan="2">
<div>
<h3><a href="http://www.spotify.com/us/mobile/overview/" rel="nofollow" target="_blank">Spotify Mobile</a></h3>
</div>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1244" title="Spotify Mobile" src="http://redbonzai.com/wp-content/uploads/2012/04/spotify-mobile-150x137.jpg" alt="Spotify Mobile" width="150" height="137" /></td>
<td>
<p>The music goes where you go.&#8221;Spotify mobile is a music application for iPhones and Android devices.Premium users can wirelessly sync favorite Spotify playlists to their phone and listen offline.</p>
<p>Free users can help themselves to the Spotify Mobile app and wirelessly sync all their own music files. There’s no access to the Spotify music library or Offline mode, but you can log in to Spotify and search for tracks.</p>
</td>
</tr>
<tr>
<td colspan="2">
<div>
<h3><a href="https://play.google.com/store/apps/details?id=com.seesmic" rel="nofollow" target="_blank">Seesmic</a></h3>
</div>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-full wp-image-1247" title="Seesmic" src="http://redbonzai.com/wp-content/uploads/2012/04/Seesmic.png" alt="Seesmic" width="124" height="124" /></td>
<td>
<p>Seesmic is an Android app that offers a way to manage social networks. Users can see and update Facebook and Twitter accounts at the same time, search, and receive notifications for new messages. Users can also share photos, videos and location using the services of your choice, such as Lockerz, yFrog, TwitPic, and YouTube.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="http://www.appbrain.com/app/words-with-friends-free/com.zynga.words" rel="nofollow" target="_blank">Words With Friends</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-full wp-image-1250" title="Words With Friends" src="http://redbonzai.com/wp-content/uploads/2012/04/Words-With-Friends.jpg" alt="Words With Friends" width="128" height="128" /></td>
<td>
<p>Play Words With Friends on your iPhone or Android Device.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="http://www.google.com/mobile/google-mobile-app_exp/index.html" rel="nofollow" target="_blank">Google Search App</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1251" title="Google Search App" src="http://redbonzai.com/wp-content/uploads/2012/04/Google-Search-App-150x150.jpg" alt="Google Search App" width="150" height="150" /></td>
<td>
<p>Download the Google Search app to your smartphone to search fast. Includes the following features: search by voice, use pictures to search the web, search your phone&#8217;s e-mail, search Google Maps, Google Images, Google Shopping, and more.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="http://store.steampowered.com/mobile" rel="nofollow" target="_blank">Steam Mobile</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1253" title="Steam Mobile" src="http://redbonzai.com/wp-content/uploads/2012/04/steam-150x44.png" alt="Steam Mobile" width="150" height="44" /></td>
<td>
<p>Steam on your mobile phone is the easiest way to keep up with your Steam friends while on the go.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="http://www.myfitnesspal.com/mobile" rel="nofollow" target="_blank">My Fitness Pal</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1254" title="My Fitness Pal" src="http://redbonzai.com/wp-content/uploads/2012/04/My-Fitness-Pal-150x150.jpg" alt="My Fitness Pal" width="150" height="150" /></td>
<td>
<p>Now you can log your food and exercise wherever and whenever you&#8217;d like &#8211; even if you can&#8217;t get to a computer.With our mobile apps for iPhone, iPad, Android, Blackberry, and Windows Phone 7, your MyFitnessPal account is always at your fingertips.</p>
<p>All our apps work with our website and have access to the same comprehensive database of over 1,620,000 foods and restaurant items. Any changes you make on your phone will be synchronized to the web and vice versa — so you always have complete and up-to-date access to your account.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="http://www.skype.com/intl/en-us/get-skype/on-your-mobile/download/" rel="nofollow" target="_blank">Skype Mobile</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1255" title="Skype Mobile" src="http://redbonzai.com/wp-content/uploads/2012/04/Skype-Mobile-150x150.jpg" alt="Skype Mobile" width="150" height="150" /></td>
<td>
<p>Take free, unlimited Skype-to-Skype calls and IMs on the go with your BlackBerry or Android 36 smartphones, but only on Verizon.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="http://itunes.apple.com/us/app/foodgawker/id428828418?mt=8" rel="nofollow" target="_blank">FoodGawker Mobile</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1257" title="FoodGawker" src="http://redbonzai.com/wp-content/uploads/2012/04/FoodGawker-150x150.jpg" alt="FoodGawker" width="150" height="150" /></td>
<td>
<p>Browse FoodGawker on your iOS phone. &#8220;Let your eyes discover what you want by browsing tens of thousands of beautifully photographed food images.</p>
</td>
</tr>
<tr>
<td colspan="2">
<h3><a href="https://foursquare.com/apps/" rel="nofollow" target="_blank">FourSquare</a></h3>
</td>
</tr>
<tr>
<td style="text-align: center;" valign="top"><img class="alignnone size-thumbnail wp-image-1259" title="FourSquare" src="http://redbonzai.com/wp-content/uploads/2012/04/FourSquare-150x120.jpg" alt="FourSquare" width="150" height="120" /></td>
<td>
<p>Check in to your favorite locations. FourSquare offers several mobile apps, including Check In, Fast Tag Check In, Dish Freely, Spot Trivia, and more.</p>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/free-mobile-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Modules in the Header for OpenCart</title>
		<link>http://redbonzai.com/create-modules-in-the-header-for-opencart/</link>
		<comments>http://redbonzai.com/create-modules-in-the-header-for-opencart/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 07:05:34 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[OpenCart Development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[premium tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[adding modules in the header opencart]]></category>
		<category><![CDATA[How to add modules in the header opencart]]></category>
		<category><![CDATA[Opencart web development]]></category>
		<category><![CDATA[php web development]]></category>

		<guid isPermaLink="false">http://redbonzai.com/?p=1201</guid>
		<description><![CDATA[Suppose we want to add a slideshow module in the header of an OpenCart website. First we have to add a new position in the back end. This means you should change three files and add some lines into each. You should add a new position in admin/controller/slideshow.php $this->data['text_header'] = $this->language->get('text_header'); Then do this in [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose we want to add a slideshow module in the header of an OpenCart website.<br />
First we have to add a new position in the back end. This means you should change three files and add some lines into each.</p>
<p>You should add a new position in  <code> admin/controller/slideshow.php</code> <br/></p>
<div style="width:600px; background:#f3f3f3;">
<pre class="brush:php">
$this->data['text_header'] = $this->language->get('text_header'); 
</pre>
</div>
<p>Then do this in <code>admin/language/slideshow.php</code></p>
<div style="width:600px; background:#f3f3f3;">
<pre class="brush:php">
$_['text_header']   = 'Header'; // in admin/language/slideshow.php
</pre>
</div>
<p><br/><br />
Now go to <code>admin/view/slideshow.tpl</code> </p>
<div style="width:600px; background:#f3f3f3;">
<pre class="brush:php">
&lt;?php <br />
if ($module['position'] == 'header') { ?&gt; <br />
&lt;option value=&quot;header&quot; selected=&quot;selected&quot;&gt;&lt;?php echo $text_header; ?&gt;&lt;/option&gt;<br />
&lt;?php } else { ?&gt;<br />
&lt;option value=&quot;header&quot;&gt;&lt;?php echo $text_header; ?&gt;&lt;/option&gt;<br />
&lt;?php } ?&gt;
</pre>
</div>
<p><br/><br />
A new position for slideshow has been defined. and you can choose it in the admin panel now.</p>
<p>add the following code to <code>catalog/view/header.tpl</code></p>
<div style="width:600px; background:#f3f3f3;">
<pre class="brush:php">
 &lt;?php foreach ($modules as $module) { ?&gt;<br />
&lt;?php echo $module; ?&gt;<br />
&lt;?php } ?&gt;
</pre>
</div>
<p><br/></p>
<p>In the <code>catalog/controller/header.php</code>, add some codes like content_top.php does: <code> $layout_id = 1;</code></p>
<p><br/></p>
<div style="width:600px; background:#f3f3f3;">
<pre class="brush:php">
<p>$module_data = array();</p>
<p>$this-&gt;load-&gt;model('setting/extension');</p>
<p>$extensions = $this-&gt;model_setting_extension-&gt;getExtensions('module'); </p>
<p>foreach ($extensions as $extension) {<br />
  $modules = $this-&gt;config-&gt;get($extension['code'] . '_module');</p>
<p> if ($modules) {<br />
  foreach ($modules as $module) {<br />
  if ($module['layout_id'] == $layout_id &amp;&amp;
      $module['position'] == 'header' &amp;&amp; $module['status']) {<br />
  $module_data[] = array(<br />
  'code'       =&gt; $extension['code'],<br />
  'setting'    =&gt; $module,<br />
  'sort_order' =&gt; $module['sort_order']<br />
  ); <br />
  }<br />
  }<br />
  }<br />
  }</p>
<p>$sort_order = array(); </p>
<p>foreach ($module_data as $key =&gt; $value) {<br />
  $sort_order[$key] = $value['sort_order'];<br />
  }</p>
<p>array_multisort($sort_order, SORT_ASC, $module_data);</p>
<p>$this-&gt;data['modules'] = array();</p>
<p>foreach ($module_data as $module) {<br />
  $module = $this-&gt;getChild('module/' . $module['code'], $module['setting']);</p>
<p> if ($module) {<br />
  $this-&gt;data['modules'][] = $module;<br />
  }<br />
  }<br />
</p>
<p>if (file_exists(DIR_TEMPLATE . $this-&gt;config-&gt;get('config_template') . '/template/common/header.tpl')) {<br />
  $this-&gt;template = $this-&gt;config-&gt;get('config_template') . '/template/common/header.tpl';<br />
  } else {<br />
  $this-&gt;template = 'default/template/common/header.tpl';<br />
  }</p>
<p>$this-&gt;render();</p>
</pre>
</div>
<p><br/></p>
<h3>Finally, add the following code to the header template for your theme</h3>
<div style="width:600px; background:#f3f3f3;">
<pre class="brush:php">
    &lt;script type=&quot;text/javascript&quot; src=&quot;catalog/view/javascript/jquery/nivo-slider/jquery.nivo.slider.pack.js&quot;&gt;&lt;/script&gt;<br />
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;catalog/view/theme/default/stylesheet/slideshow.css&quot; media=&quot;screen&quot; /&gt;
</pre>
</div>
<p><br/><br />
<br/><br />
Your site should be working &#8230; thanks for reading. </p>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/create-modules-in-the-header-for-opencart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Custom Page in OpenCart</title>
		<link>http://redbonzai.com/create-a-custom-page-in-opencart/</link>
		<comments>http://redbonzai.com/create-a-custom-page-in-opencart/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 06:22:08 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[OpenCart Development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[premium tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[custom page in opencart]]></category>
		<category><![CDATA[Houston opencart development]]></category>
		<category><![CDATA[Opencart web development]]></category>

		<guid isPermaLink="false">http://redbonzai.com/?p=1177</guid>
		<description><![CDATA[If you want to create a custom page in opencart, there are two ways to do it : 1. You can go into the information section using the admin area. 2. You can create a controller file for your page, which points to a few other pages. In codeigniter you would create a controller and [...]]]></description>
			<content:encoded><![CDATA[<p> If you want to create a custom page in opencart, there are two ways to do it : </p>
<p> 1.  You can go into the information section using the admin area.</p>
<p> 2.  You can create a controller file for your page, which points to a few other pages.</p>
<p>In codeigniter you would create a controller and a view and if setup was needed, we would create some rules in the routes file.  This application is just a bit different.<br />
Thankfully, this is a really simple task in <strong>OpenCart web Development</strong>.</p>
<h3>How to create a custom page in OpenCart: </h3>
<p>You need to create a controller for your file, naming based on the folder and filename. For instance <code>common/home.php</code> Has the class initialization like this : </p>
<div style="width:600px; background:#f3f3f3; padding:10px; ">
<pre class="brush:php">
<code>Class ControllerCommonHome extends Controller</code>
</pre>
</div>
<p><br/></p>
<p>This is accessed using <code>index.php?route=common/home </code> and accesses the <code>index()</code> method.<br />
If you want to call another method, for instance bananas, you would need to define the method as <br/></p>
<div style="width:600px; background:#f3f3f3; padding:10px; ">
<pre class="brush:php">
public function bananas() {
    // Code here
}
</pre>
</div>
<p><br/><br />
and we would call it using <code>index.php?route=common/home/bananas</code>.<br />
Now, we need to render the view.  Simply add all of the following code to the end of your controller method :<br />
<br/></p>
<div style="width:600px; background:#f3f3f3; padding:10px; ">
<pre class="brush:php">
 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') .
     '/template/common/new_template_file.tpl')) {

        $this->template = $this->config->get('config_template') .
        '/template/common/new_template_file.tpl';
    } else {
        $this->template = 'default/template/common/new_template_file.tpl';
    }

    $this->children = array(
        'common/column_left',
        'common/column_right',
        'common/content_top',
        'common/content_bottom',
        'common/footer',
        'common/header'
    );

    $this->response->setOutput($this->render());
</pre>
</div>
<p><br/></p>
<h3>Which will render the following :</h3>
<div style="width:600px; background:#f3f3f3; padding:10px; ">
<pre class="brush:php">
 /catalog/view/theme/your-theme-name/template/common/new_template_file.tpl 
</pre>
</div>
<p>If that file doesn&#8217;t exist, it will attempt to use the same path in the default theme folder.  </p>
<p>Take a look at a few controllers and templates to get your head around where everything comes from properly, but that&#8217;s the basic gist of how creating a custom page in OpenCart works.<br />
<br/></p>
<p>We hope that you have enjoyed our short post in OpenCart Web Development.  Stay tuned &#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/create-a-custom-page-in-opencart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove the Generator tag in WordPress</title>
		<link>http://redbonzai.com/how-to-remove-the-generator-tag-in-wordpress/</link>
		<comments>http://redbonzai.com/how-to-remove-the-generator-tag-in-wordpress/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 22:09:01 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[houston website development]]></category>
		<category><![CDATA[wordpress development]]></category>
		<category><![CDATA[wordpress generator tag]]></category>

		<guid isPermaLink="false">http://redbonzai.com/?p=883</guid>
		<description><![CDATA[The WordPress Generator Tag: Remove or not? WordPress shows the version number in the meta generator tag by default. IT is probably best practices to remove it for security reasons. This is very simple to do in wordpress, just add a line of code within the functions.php file in the root of your theme. To [...]]]></description>
			<content:encoded><![CDATA[<h2>The WordPress Generator Tag: Remove or not?</h2>
<p><span id="more-883"></span></p>
<div class="dropcap dc-W">W</div>
<p>WordPress shows the version number in the meta generator tag by default. IT is probably best practices to remove it for security reasons. This is very simple to do in wordpress, just add a line of code within the functions.php file in the root of your theme.</p>
<h3>To remove meta generator tag in wordpress, follow the steps below:</h3>
<div class="checklist">
<ul>
<li>Login into your wordpress admin panel as administrator.</li>
<li>Go to Appearance -&gt; Editor and click on the file functions.php</li>
<li> Go to the bottom of the page and add the following line of code before the ?&gt; and click Update.</li>
</ul>
</div>
<h4>
It goes like this :</h4>
<p><br style="clear:both;"/></p>
<div style="width:100%; height:40px; background:#f4f4f4; border:#dddddd; padding:15px; text-align:center;">
<code>remove_action('wp_head', 'wp_generator');</code>
</div>
<p><br/></p>
<div class="dropcap dc-I">I</div>
<p>f you do not have functions.php file, you may create one with the content below and upload to your theme folder:<br />
<br/></p>
<h4>Then type the following : </h4>
<p><br/></p>
<div style="width:100%; height:40px; background:#f4f4f4; border:#dddddd; padding:15px; text-align:center;">
<code><br />
&lt;?php remove_action('wp_head', 'wp_generator'); ?&gt;</code>
</div>
<p></p>
<p>Done, you have just removed meta generator tag in wordpress<br />
Now clear your wordpress cache (if you have any) and visit the source of the front page to verify the existence of meta generator tag.  </p>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/how-to-remove-the-generator-tag-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is Keyword Density ?</title>
		<link>http://redbonzai.com/what-is-key-word-density/</link>
		<comments>http://redbonzai.com/what-is-key-word-density/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 02:20:35 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[houston seo services]]></category>
		<category><![CDATA[keyword density]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[houston seo marketing]]></category>
		<category><![CDATA[How to get the right keywords on your website]]></category>
		<category><![CDATA[Seo keyword density]]></category>
		<category><![CDATA[What is keyword density in SEO]]></category>

		<guid isPermaLink="false">http://redbonzai.com/?p=459</guid>
		<description><![CDATA[How frequently should you use your keyword to rate highly for it in the search engines? How can you avoid penalties for keyword stuffing? Do the different search engines have different standards for the amount of times you can use your keyword on your site without invoking a penalty? Wayne Hurlbert tackles these and other [...]]]></description>
			<content:encoded><![CDATA[<p>How frequently should you use your keyword to rate highly for it in the search engines? How can you avoid penalties for keyword stuffing? Do the different search engines have different standards for the amount of times you can use your keyword on your site without invoking a penalty? Wayne Hurlbert tackles these and other questions in this article.<br />
What is keyword density?</p>
<p>Keyword density is a combination of the number of times a keyword or a keyword phrase, in proportion with other words, appears on a Web page. The more times the keyword appears in relation to the total number of on page words, the greater the overall keyword density. The more times that other words appear, the lower the proportion of keywords, resulting in a lighter keyword density.</p>
<p>Does keyword density make a difference?</p>
<p>The various search engines, including Google, Yahoo, and MSN Search consider keyword density as part of their search algorithm. Each search engine has a different mathematical equation regarding the density of keywords that is rewarded with higher search ranking placement. There is also a different level of tolerance between the different search engines as to the degree of density permitted before a penalty is imposed.</p>
<p>Okay, so what are keywords anyway?</p>
<p>Keywords are the terms that searchers enter into the search engine&#8217;s search interface when seeking information, products, or services. The keyword is entered into the search engine algorithm as a mathematical calculation, to determine relevance of the many billions of Internet pages to that particular search. The pages the algorithm deems most relevant to the search for those keywords are ranked accordingly.</p>
<p>How are keywords different from keyword phrases?</p>
<p>A keyword can be one single word or a phrase including that word. Searchers use both types of entries when seeking information. As a general rule, the longer the phrase, the more specific the returned information will be from the search engine index.</p>
<h3/>
<h3>Different search engines treat keyword density differently?</h3>
<p>It’s generally thought by search engine optimization experts that Yahoo and MSN Search tolerate heavier keyword densities per page than industry leader Google. As with all areas of SEO, there is some debate on this issue, and counter examples are very likely to be found. Generally, however, Google is less tolerant of heavy keyword usage than Yahoo or MSN.</p>
<p>Is there a formula for keyword density?</p>
<p>There is no hard and fast formula for keywords but it’s probably best to keep the keyword percentage below five percent of the total number of words on the page. Any more words could potentially trigger a keyword stuffing filter. Too many keywords in any on page copy can also work against the page’s readership retention and its conversion rate from visitor to paying customer. After all, the purpose of a Web page, for any commercial website, is to convert visitors to customers. For an informational website, the goal is to have as many visitors as possible read the available information. Badly written copy precludes those things from happening.</p>
<p>Is keyword density different from keyword placement?</p>
<p>Keyword density refers to the amount of keywords used on the page, in relation to the total number of words on the page in question. Keyword placement refers to the location of the words on a Web page. That placement could be in the title tags, links, headings, main body of copy, or anywhere else where wording appears on a Web page.</p>
<p>Does the order of keywords make a difference?</p>
<p>Some SEO experts believe that placing keywords higher on the page gives that page a boost in the search rankings. That opinion is not shared by all search engine observers, however. In general, it’s better to sprinkle the keywords throughout the on page copy in a normal writing fashion. Natural sounding content is much easier to read, and could even score as well in the search rankings as any special placements on the page.</p>
<p>Can keywords help as link anchor text?</p>
<p>Link anchor text is a common usage of keywords and has little effect on keyword density of the sending or receiving page. For purposes of SEO, link anchor text, comprised of the receiving page’s most important keywords, is probably more powerful than heavier use of keywords in on page copy. Keywords in link anchor text tell the search engines what the receiving page is about in terms of themes and topics. A form of keyword stuffing, that appears unnatural to the search engines, is the use of exactly the same keywords in all incoming link anchor text. Keywords and phrases are best mixed and matched, with several variations of link anchor text employed. </p>
<hr/>
<h3> Are keywords important in title tags? </h3>
<p>The use of keywords in title tags is a powerful placement of the page’s most important search terms. In title tags, the placement of keywords is important. The most important keywords should be placed at the beginning of the page title tag. As with all keywords, there is danger of keyword stuffing in the title tags themselves. Be sure to refrain from using any word more than three times in the title tag. A maximum of twice would be even safer to prevent triggering a keyword stuffing filter. </p>
<p>Does the keyword form make a difference?</p>
<p>Keywords can be written as planned for the search engines. They can also be organized into desirable search phrases. Plural and singular forms of the words should also be utilized as many searchers will choose either one form or the other. Additional ways of writing keywords include adding -ed, -ing, or other related suffixes to reflect different searches.<br />
Plural and singular forms of a keyword will often result in vastly different search results in Google, making it important that both forms of a keyword be part of the copy if well written content is the result. If different word variations become too difficult, and if the keyword is highly competitive, it’s preferable to create an entirely new page for each alternative form of the word, to concentrate the keyword power of the page.</p>
<p>Should different keywords be used in the on page copy?</p>
<p>It’s a good idea to use different keywords on the Web page. By doing so, the page could rank well for other searches, many of which might result in more traffic or sales than the originally targeted keyword or phrase. The different words also make the page more pleasant for visitors to read, greatly enhancing the site’s length of stays and sales conversion rates. In highly competitive situations, however, the best course of action is often to create separate Web pages for each different keyword or phrase.</p>
<p>What is the best way to write on page copy?</p>
<p>The best way to write Web page copy is in an easy to read format. The copy should flow freely, and lead the visitor either to convert to a customer, or to seek even more information from the website. Placing the sought after keywords in natural locations throughout the information, in the page headings, and title tags will enhance the page’s keyword value. It will also prevent keyword stuffing possibilities as the keywords are not all packed into the page’s informational or sales copy.</p>
<h3>Are there any tools for calculating keyword density? </h3>
<p>A number of good keyword density tools are available. They include:<br />
Search Engine World’s Keyword Density Analyzer http://www.searchengineworld.com/cgi_bin/kwda.cgi,</p>
<p>Keyword Density Analyzer http://www.virtualpromote.com/tools/keyword_analyzer/,</p>
<p>and SEO Chat’s SEO Tools &#8211; Keyword Density http://www.seochat.com/seo_tools/keyword_density/</p>
<p>There are many more good tools available with a simple search.</p>
<p>Can a Web page have too many keywords?</p>
<p>In theory, a web page can have an almost unlimited numbers of keywords provided that the page contains enough other words to balance them. In practice, however, a page should most certainly contain five percent keywords or fewer. The reason for restricting the number of keywords is not strictly to avoid Google filters. It’s also to keep the copy easily readable for the visitors. Badly written copy is not informative or good sales or marketing material. Any minimal benefit derived from slightly higher search rankings is more than offset by a rapid loss of visitor traffic and potential customers.</p>
<p>What is keyword stuffing?</p>
<p>Keyword stuffing is the very intensive placement of keywords within a Web page’s copy. In general, the level of keywords would be so frequent as to overwhelm the rest of the copy. While the overuse of keywords is likely to trigger a Google filter, the potential loss of visitor traffic due to hard to read content is a much larger problem. A searcher finding a Web page consisting of keywords obviously jammed in everywhere is highly unlikely to remain and convert to a paying customer. The loss due to keyword stuffing is therefore twofold. </p>
<p>What are some common forms of keyword stuffing?</p>
<p>Keyword stuffing can result from jamming as many of the keywords into the page’s informational copy as possible. The copy reads like a string of keywords and little else. Another form of keyword stuffing is to pack the word or words as many times as possible into the page title tags. The search engines will often downgrade the page in the search rankings, or perhaps ignore the keywords entirely. Neither result is beneficial to the website. Keyword stuffed doorway pages or cloaked pages are not only examples of keyword overuse, but are also penalty causing items in their own right. The constant and complete usage of the same link anchor text for all inbound links can be considered a form of keyword stuffing as well. </p>
<p>Can a site be penalized for keyword stuffing?</p>
<p>A site can and will be penalized by the search engines for keyword stuffing. Google appears to be very sensitive to overuse of keywords on the page, as a filter will be triggered. Penalties ranging from a downgrade in the search results, to the loss of Google PageRank, to possibly being banned are options that the search engine giant could consider imposing on the site. As with all search engine optimization efforts, common sense and thinking of what benefits your site’s visitors is the best action for any website owner to use.</p>
<div style="width:300px;">
<img src="http://redbonzai.com/rbSupport/admin/images/loginlogo.png" alt="RedBonzai Developers, INC is a Houston website development company creating enterprise level websites and software for small businesses." title="RedBonzai Developers, INC is a Houston website development company creating enterprise level websites and software for small businesses." width="300"/>
</div>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/what-is-key-word-density/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create a Digital Shopping Cart with CodeIgniter</title>
		<link>http://redbonzai.com/how-to-create-a-digital-shopping-cart-with-codeigniter/</link>
		<comments>http://redbonzai.com/how-to-create-a-digital-shopping-cart-with-codeigniter/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 15:17:53 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[premium tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CodeIgniter Applications]]></category>
		<category><![CDATA[Create a CodeIgniter Shopping cart]]></category>
		<category><![CDATA[e-commerce]]></category>
		<category><![CDATA[How to sell Digital Items with CodeIgniter]]></category>
		<category><![CDATA[php Development]]></category>
		<category><![CDATA[Web application Development]]></category>
		<category><![CDATA[Web Application Development Houston Tx]]></category>
		<category><![CDATA[Web Developer Houston Tx]]></category>

		<guid isPermaLink="false">http://www.redbonzai.com/blog/?p=317</guid>
		<description><![CDATA[RedBonzai Developers, INC is a group of web application developers dedicated to serious web development in Houston, Tx. We are currently expanding our repertoire to CodeIgniter Applications. We will talk quite a bit about E-Commerce in times to come, but in particular we are using our PHP development skills to create a CodeIgniter Shopping Cart [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-350" title="Code Igniter" src="http://redbonzai.com/wp-content/uploads/2010/10/codeIgniter.jpg" alt="RedBonzai Developers, INC. is a web development firm serious about web development in Houston, Tx. Look to us for E-Commerce applications using CodeIgniter framework. Look to redbonzai for custom webdesign, and web development. We create custom Content Management Systems for joomla and WordPress." width="625" height="391" /></p>
<p class="biglines">RedBonzai Developers, INC is a group of web application developers dedicated to serious web development in Houston, Tx. We are currently expanding our repertoire to CodeIgniter Applications. We will talk quite a bit about E-Commerce in times to come, but in particular we are using our PHP development skills to create a CodeIgniter Shopping Cart that will fully equip you to sell digital goods online.<br />
This is a tutorial originally authored by Dan Harper, and we will be expanding on it a bit. The CodeIgniter Image above is credited to Nucleocide.</p>
<h2>Getting Started</h2>
<p><script type="text/javascript">// <![CDATA[
google_ad_client = "pub-7439518364115179";
/* 728x90, redbonzai Posts */
google_ad_slot = "2826230417";
google_ad_width = 650;
google_ad_height = 90;
// ]]&gt;</script><br />
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<p class="biglines">Download the latest <a href="http://codeigniter.com/download.php">CodeIgniter release</a> to your server, and set up your MySQL database (I named it <code>digitalgoods</code>) with the following SQL queries:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="brush:mysql">CREATE TABLE `ci_sessions` (
  `session_id` varchar(40) NOT NULL DEFAULT '0',
  `ip_address` varchar(16) NOT NULL DEFAULT '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
  `user_data` text NOT NULL,
  PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `downloads` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) DEFAULT NULL,
  `purchase_id` int(11) DEFAULT NULL,
  `download_at` int(11) DEFAULT NULL,
  `ip_address` varchar(15) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `description` text,
  `price` decimal(10,2) DEFAULT NULL,
  `file_name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `purchases` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) DEFAULT NULL,
  `key` varchar(255) DEFAULT NULL,
  `email` varchar(127) DEFAULT NULL,
  `active` tinyint(1) DEFAULT NULL,
  `purchased_at` int(11) DEFAULT NULL,
  `paypal_email` varchar(127) DEFAULT NULL,
  `paypal_txn_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `items` (`id`,`name`,`description`,`price`,`file_name`)
VALUES
  (1, 'Unix and CHMOD', 'Vivamus id mollis quam. Morbi ac commodo nulla.', 19.99, 'UNIX and CHMOD.txt'),
  (2, 'Intro to 8086 Programming', 'Morbi ac commodo nulla.', 4.95, 'Intro to 8086 Programming.txt');</pre>
</div>
<p>&nbsp;</p>
<p class="biglines">The first query creates CodeIgniter&#8217;s default user sessions table. We then create a table to log file downloads, one to store the items and another to store purchase details. Finally, we insert a couple of items into the table.</p>
<p class="biglines">We&#8217;ve inserted two items into the database, so we have to create those files on the server. In the root directory for your application (the same folder as CodeIgniter&#8217;s <code>system</code> directory), create a new directory named <code>files</code>:</p>
<p><br/> </p>
<p class="biglines">In that directory, create two text files, named <code>UNIX and CHMOD.txt</code> and <code>Intro to 8086 Programming.txt</code>. The capital letters are important on most web servers. These are the file names we set in the database for our two items. Enter some content in the files so we can be sure the files are being downloaded correctly.</p>
<h3>CodeIgniter Configuration</h3>
<p class="biglines">In the <code>system/application/config/database.php</code> file, set your database settings in the fields provided:</p>
<p>&nbsp;</p>
<div></div>
<p>&nbsp;</p>
<p><script type="text/javascript">// <![CDATA[
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 650;
google_ad_height = 90;
// ]]&gt;</script><br />
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<p class="biglines">In <code>config/autoload.php</code> set the following libraries and helpers:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="brush:php">$autoload['libraries'] = array( 'database', 'session', 'form_validation', 'email' );
...
$autoload['helper'] = array( 'url', 'form', 'download', 'file' );</pre>
</div>
<p>&nbsp;</p>
<p class="biglines">In <code>config/config.php</code> set the base_url:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="php">$config['base_url']	= "http://localhost/digitalgoods/";</pre>
</div>
<p>&nbsp;</p>
<p class="biglines">In the same file, paste the following to create our own configuration settings:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="brush:php">/*
|--------------------------------------------------------------------------
| Website Name
|--------------------------------------------------------------------------
|
| Will be used on page title bars, in emails etc.
|
*/
$config['site_name'] = "Digital Goods";

/*
|--------------------------------------------------------------------------
| Admin Email
|--------------------------------------------------------------------------
|
| Used to send confirmations of purchases
|
*/
$config['admin_email'] = "dan@example.com";

/*
|--------------------------------------------------------------------------
| No-Reply Email
|--------------------------------------------------------------------------
|
| The 'No-Reply' address used to send out file downloads
|
*/
$config['no_reply_email'] = "noreply@example.com";

/*
|--------------------------------------------------------------------------
| PayPal Account
|--------------------------------------------------------------------------
|
| The email address PayPal payments should be made to
|
*/
$config['paypal_email'] = "paypal@example.com";

/*
|--------------------------------------------------------------------------
| Download Limit
|--------------------------------------------------------------------------
|
| How many times can an item be downloaded within a certain time frame?
|   eg. 4 downloads within 7 days
|
*/
$config['download_limit'] = array(
	'enable'	=&gt; false,
	'downloads'	=&gt; '4',
	'days'		=&gt; '7'
);</pre>
</div>
<p>&nbsp;</p>
<p><script type="text/javascript">// <![CDATA[
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 650;
google_ad_height = 90;
// ]]&gt;</script><br />
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<p class="biglines">Set each of the new config options to your desired settings, but keep &#8216;Download Limit&#8217; disabled for now.</p>
<p class="biglines">Finally, under <code>config/routes.php</code> set the default controller:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="php">$route['default_controller'] = "items";</pre>
</div>
<p>&nbsp;</p>
<h2>View All Items</h2>
<p class="biglines">Now to create the main controller for the site, create a file in the <code>controllers</code> directory named <code>items.php</code>, and inside enter:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="brush:php">&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Items extends Controller {

    function Items() {
        parent::Controller();
        $this-&gt;load-&gt;model( 'items_model', 'Item' );
        $data['site_name'] = $this-&gt;config-&gt;item( 'site_name' );
        $this-&gt;load-&gt;vars( $data );
    }

    function index() {
        echo 'Hello, World!';
    }

}</pre>
</div>
<p>&nbsp;</p>
<p class="biglines">In the constructor we&#8217;ve loaded in the &#8216;items_model&#8217; model (which we&#8217;ve named &#8216;Item&#8217;) which we&#8217;ll create next, and placed the &#8216;site_name&#8217; configuration setting into a variable which we can access in the views. For the index method, we&#8217;ve just set a simple &#8216;Hello, World!&#8217; message for now.</p>
<p class="biglines">Also, create a new model by creating new file in the <code>models</code> directory named <code>items_model.php</code> and inside enter:</p>
<p>&nbsp;</p>
<div id="" class="php" title="" lang="&quot;en&quot;&gt;">controllers/create a file named <code>paypal.php</code>and enter the following inside:</p>
<pre class="php">&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Paypal extends Controller {

  function Paypal() {
    parent::Controller();
    $this-&gt;load-&gt;model( 'items_model', 'Item' );
    $this-&gt;load-&gt;library( 'Paypal_Lib' );
    $data['site_name'] = $this-&gt;config-&gt;item( 'site_name' );
    $this-&gt;load-&gt;vars( $data );
  }

  function index() {
    redirect( 'items' );
  }

  function success() {
    $this-&gt;session-&gt;set_flashdata( 'success', 'Your payment is being processed now.
Your download link will be emailed to your shortly.' );
    redirect( 'items' );
  }

  function cancel() {
    $this-&gt;session-&gt;set_flashdata( 'success', 'Payment cancelled.' );
    redirect( 'items' );
    }

}</pre>
<p>That&#8217;s the &#8216;success&#8217; and &#8216;cancel&#8217; pages (cancel is used with a user doesn&#8217;t continue with the payment and clicks the cancel button on PayPal instead).</p>
<h3>PayPal Developer Tools</h3>
<p>PayPal provide a &#8216;Sandbox&#8217; for developers to test their code with. You can create your own sandbox PayPal addresses to send pretend payments. Sign up for a free developer account at <a href="https://developer.paypal.com/">https://developer.paypal.com/</a> then go to &#8216;Create a preconfigured buyer or seller account&#8217;:</p>
<p>Fill out the form to create a new buyer account, enter a balance and click on through. On the &#8216;Test Accounts&#8217; page you will find the email address for your new Sandbox buyer email address:</p>
<p>Now go back to the site we&#8217;re creating and click through to purchase an item. Notice that when you get to PayPal, the address is <code>https://www.<strong>sandbox.</strong>paypal.com/....</code>. Login with the &#8216;buyer&#8217; account you created on the right:</p>
<p>Continue through the payment process and click the &#8216;Return to Merchant&#8217; button upon completion. You should be directed back to your homepage, with the &#8220;Your payment is being processed now. Your download link will be emailed to your shortly.&#8221; message below the header.</p>
<p>The main interface of the site is now complete. We just need to add in our IPN listener and email the item to the buyer.</p>
<h2>IPN Listener</h2>
<p>As mentioned above, once PayPal has confirmed payment, it will send data to our IPN listener, once we validate the data with PayPal (to prevent fraudulent data), we can use the data to activate the buyer&#8217;s purchase.</p>
<p>The IPN function is a little big, so I&#8217;ll break it up. Inside the PayPal controller, add the following function:</p>
<pre class="php">function ipn() {
  if ( $this-&gt;paypal_lib-&gt;validate_ipn() ) {
    $item_name = $this-&gt;paypal_lib-&gt;ipn_data['item_name'];
    $price = $this-&gt;paypal_lib-&gt;ipn_data['mc_gross'];
    $currency = $this-&gt;paypal_lib-&gt;ipn_data['mc_currency'];
    $payer_email = $this-&gt;paypal_lib-&gt;ipn_data['payer_email'];
    $txn_id = $this-&gt;paypal_lib-&gt;ipn_data['txn_id'];
    $key = $this-&gt;paypal_lib-&gt;ipn_data['transaction_subject'];

    $this-&gt;Item-&gt;confirm_payment( $key, $payer_email, $txn_id );
    $purchase = $this-&gt;Item-&gt;get_purchase_by_key( $key );
    $item = $this-&gt;Item-&gt;get( $purchase-&gt;item_id );
  }
}</pre>
<p>Right at the start we validate the data sent to the listener with PayPal – the library takes care of all this. If the data is valid, we grab a some details (the item name, price, currency, the payer&#8217;s PayPal email address, the transaction ID and the unique key we sent to PayPal when the payment process began).</p>
<p>We can then use the key to confirm the payment (by setting the &#8216;active&#8217; field to &#8217;1&#8242;) and add the payer&#8217;s PayPal email and transaction ID to the database for future reference.</p>
<p>Using the key we can get the purchase details from the database, along with the item purchased. Before continuing with the IPN function, let&#8217;s create the <code>confirm_payment()</code> and <code>get_purchase_by_key()</code> model methods.</p>
<p>So inside the model, add the following:</p>
<pre class="php">function confirm_payment( $key, $paypal_email, $payment_txn_id ) {
  $data = array(
    'purchased_at'  =&gt; time(),
    'active'        =&gt; 1,
    'paypal_email'  =&gt; $paypal_email,
    'paypal_txn_id' =&gt; $paypal_txn_id
  );
  $this-&gt;db-&gt;where( 'key', $key );
  $this-&gt;db-&gt;update( 'purchases', $data );
}

function get_purchase_by_key( $key ) {
  $r = $this-&gt;db-&gt;where( 'key', $key )-&gt;get( 'purchases' )-&gt;result();
  if ( $r ) return $r[0];
  return false;
}</pre>
<p>The functions should be pretty self explanatory by now, so now we need to email the customer their download link. This is handled in the IPN listender, so back in the controller add the following to the end of the <code>ipn()</code> function:</p>
<pre class="php">// Send download link to customer
$to = $purchase-&gt;email;
$from = $this-&gt;config-&gt;item( 'no_reply_email' );
$name = $this-&gt;config-&gt;item( 'site_name' );
$subject = $item-&gt;name . ' Download';

$segments = array( 'item', url_title( $item-&gt;name, 'dash', true ), $item-&gt;id );
$message = '&lt;p&gt;Thanks for purchasing ' . anchor( $segments, $item-&gt;name ) . ' from ' . anchor( '', $name ) . '.
Your download link is below.&lt;/p&gt;';
$message .= '&lt;p&gt;' . anchor( 'download/' . $key ) . '&lt;/p&gt;';

$this-&gt;email-&gt;from( $from, $name );
$this-&gt;email-&gt;to( $to );
$this-&gt;email-&gt;subject( $subject );
$this-&gt;email-&gt;message( $message );
$this-&gt;email-&gt;send();
$this-&gt;email-&gt;clear();</pre>
<p>Here we&#8217;re using CodeIgniter&#8217;s Email class to send the email. We start by setting up &#8216;To&#8217;, &#8216;From&#8217;, &#8216;Name&#8217; and &#8216;Subject&#8217; variables with the relevant data.</p>
<p>We then write a short message for the body with a link to the file they purchased, followed by their download link (which will be in the format of: <code>http://example.com/download/{key}</code>). Finally we add the variables into the Email class methods and send it.</p>
<p>The final thing we need in the IPN listener is to send the site&#8217;s admin an email with the transaction details. Add the following to the end of the <code>ipn()</code> function:</p>
<pre class="php">// Send confirmation of purchase to admin
$message = '&lt;p&gt;&lt;strong&gt;New Purchase:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;';
$message .= '&lt;li&gt;&lt;strong&gt;Item:&lt;/strong&gt; ' . anchor( $segments, $item-&gt;name ) . '&lt;/li&gt;';
$message .= '&lt;li&gt;&lt;strong&gt;Price:&lt;/strong&gt; $' . $item-&gt;price . '&lt;/li&gt;';
$message .= '&lt;li&gt;&lt;strong&gt;Email:&lt;/strong&gt; ' . $purchase-&gt;email . '&lt;/li&gt;&lt;li&gt;&lt;/li&gt;';
$message .= '&lt;li&gt;&lt;strong&gt;PayPal Email:&lt;/strong&gt; ' . $payer_email . '&lt;/li&gt;';
$message .= '&lt;li&gt;&lt;strong&gt;PayPal TXN ID:&lt;/strong&gt; ' . $txn_id . '&lt;/li&gt;&lt;/ul&gt;';
$this-&gt;email-&gt;from( $from, $name );
$this-&gt;email-&gt;to( $this-&gt;config-&gt;item( 'admin_email' ) );
$this-&gt;email-&gt;subject( 'A purchase has been made' );
$this-&gt;email-&gt;message( $message );
$this-&gt;email-&gt;send();
$this-&gt;email-&gt;clear();</pre>
<p><strong>IMPORTANT!</strong> The IPN listener won&#8217;t work if you&#8217;re running on a local server (&#8216;localhost&#8217;). Clearly if PayPal attempted to visit <code>http://localhost/paypal/ipn/</code> they&#8217;re not going to arrive at your system. Upload your files to a remote server accessible by a domain name, or external IP address, for this to work.</p>
<h2>File Downloads</h2>
<p>The final step to getting the site fully working is to get the download links to work. When a customer goes to the download link we email them (eg. <code>http://example.com/download/{key}</code>), we use their key to look up the download. If the purchase associated with the key is set to active (payment fulfilled) and the file exists on the server, the download will start.</p>
<p>First thing we need to do is add another route to set <code>/download/</code> requests to go to <code>items/download</code>. Add the following to your <code>config/routes.php</code> file:</p>
<pre class="php">$route['download/:any'] = 'items/download';</pre>
<p>Now, inside your items controller, add the following <code>download()</code> method:</p>
<pre class="php">function download() { // ROUTE: download/{purchase_key}
  $key = $this-&gt;uri-&gt;segment( 2 );
  $purchase = $this-&gt;Item-&gt;get_purchase_by_key( $key );

  // Check purchase was fulfilled
  if ( ! $purchase ) {
    $this-&gt;session-&gt;set_flashdata( 'error', 'Download key not valid.' );
    redirect( 'items' );
  }
  if ( $purchase-&gt;active == 0 ) {
    $this-&gt;session-&gt;set_flashdata( 'error', 'Download not active.' );
    redirect( 'items' );
  }

  // Get item and initiate download if exists
  $item = $this-&gt;Item-&gt;get( $purchase-&gt;item_id );

  $file_name = $item-&gt;file_name;
  $file_data = read_file( 'files/' . $file_name );

  if ( ! $file_data ) { // file not found on server
    $this-&gt;session-&gt;set_flashdata( 'error', 'The requested file was not found. Please contact us to resolve this.' );
    redirect( 'items' );
  }

  force_download( $file_name, $file_data );
}</pre>
<p><script type="text/javascript">// <![CDATA[
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 650;
google_ad_height = 90;
// ]]&gt;</script><br />
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">// <![CDATA[</p>
<p>// ]]&gt;</script></p>
<p>In the first couple lines we lookup the purchase using the key in the URL. On line 6, if we can&#8217;t find a purchase record with that key, we set an error message that the key is invalid and redirect the user to the homepage. Similarly, on line 10, if the purchase was not fulfilled (active is &#8217;0&#8242;), we display an error.</p>
<p>We then retrieve the actual item from the database, and retrieve the file name. We use the <code>read_file()</code> method from CodeIgniter&#8217;s File helper to get the contents of the file. If the file can&#8217;t be found (or is empty), we display an error. Otherwise, we use the <code>force_download()</code> method to initiate a download.</p>
<h3>Item Theft</h3>
<p>We do have one problem—it&#8217;s possible to guess the name of a file and download it directly (ie. by visiting <code>http://example.com/files/UNIX and CHMOD.txt</code>). To fix this, simply create a file named <code>.htaccess</code> inside the <code>files/</code> directory with the following line inside:</p>
<pre class="php">deny from all</pre>
<p>This tells the server to deny any requests for files in this directory – but the server itself can still access the files so buyers can still download using their own unique link.</p>
<h2>Stylish</h2>
<p>At the root of your app (same location as the <code>files</code> and <code>system</code> directories), create a new directory named <code>css</code>, inside it create a file named <code>style.css</code> and add the following inside to spice things up a little:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="brush:css">body {
  background-color: #f9f9f9;
  color: #222;
  font-family: sans-serif;
}

#wrap {
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  box-shadow: #e6e6e6 0 0 15px;
  -moz-box-shadow: #e6e6e6 0 0 15px;
  -webkit-box-shadow: #e6e6e6 0 0 15px;
  margin: 15px auto;
  padding: 15px;
  width: 760px;
}

a {
  color: #24badb;
  text-decoration: none;
}

header h1 {
  text-align: center;
}

header a {
  color: #222;
  padding: 7px 10px;
}

header a:hover {
  background-color: #222;
  color: #fff;
}

li {
  margin-bottom: 10px;
}

section {
  line-height: 1.5em;
}

section a {
  padding: 3px 4px;
}

section a:hover {
  background-color: #24badb;
  color: #fff;
}

footer {
  color: #bbb;
  text-align: right;
}

footer a {
  color: #bbb;
}

footer a:hover {
  color: #a0a0a0;
}</pre>
<p>&nbsp;</p>
<div style="background-color: #f7f7f7; border-top: 1px solid #fff; border-bottom: 1px solid #fff; padding: 10px; text-align: center; margin-bottom: 10px;"><img src="http://redbonzai.com/wp-content/uploads/2010/10/styled.png" alt="" border="0" /></div>
<h2><span>BONUS: </span>Download Limits</h2>
<p>You may want to limit how often a user may download their purchase within a certain time period (perhaps to stop them sharing the download link around). Implementing this feature doesn&#8217;t take much work, so let&#8217;s add it in now.</p>
<p>We already set up a database table to log file downloads–&#8217;downloads&#8217;–which we haven&#8217;t used yet. We also have the &#8216;Download Limit&#8217; setting in the <code>config/config.php</code> file, so go ahead and &#8216;enable&#8217; it now:</p>
<pre class="php">/*
|--------------------------------------------------------------------------
| Download Limit
|--------------------------------------------------------------------------
|
| How many times can an item be downloaded within a certain time frame?
|   eg. 4 downloads within 7 days
|
*/
$config['download_limit'] = array(
	'enable'	=&gt; true,
	'downloads'	=&gt; '4',
	'days'		=&gt; '7'
);</pre>
<p>The default setting is to allow up to four file downloads in a seven day period. If, for example, the buyer tries to download <em>five</em> times in seven days, we&#8217;ll forward them back to the home page and display an error explaining why we can&#8217;t serve up their download right now.</p>
<p>The first thing we need to do is keep a log every time a download is initiated. To do this, add the following directly before the <code>force_download(...)</code> statement at the end of the <code>download()</code> function in the Items controller:</p>
<pre class="php">$this-&gt;Item-&gt;log_download( $item-&gt;id, $purchase-&gt;id, $this-&gt;input-&gt;ip_address(), $this-&gt;input-&gt;user_agent() );</pre>
<p>Here we&#8217;re sending the item id, purchase id and the user&#8217;s IP address and user agent to a <code>log_download()</code> method in the Items model which we&#8217;ll create next.</p>
<p>Add the following method to your Items_model:</p>
<pre class="php">function log_download( $item_id, $purchase_id, $ip_address, $user_agent ) {
  $data = array(
    'item_id'      =&gt; $item_id,
    'purchase_id'  =&gt; $purchase_id,
    'download_at'  =&gt; time(),
    'ip_address'   =&gt; $ip_address,
    'user_agent'   =&gt; $user_agent
  );
  $this-&gt;db-&gt;insert( 'downloads', $data );
}</pre>
<p>This simply adds the data we provided, and the current time, to the &#8216;downloads&#8217; table.</p>
<p>We&#8217;ll also need a method to get the downloads of a purchase, so add the following to the model:</p>
<pre class="php">function get_purchase_downloads( $purchase_id, $limit ) {
  return $this-&gt;db-&gt;where( 'purchase_id', $purchase_id )-&gt;limit( $limit )-&gt;order_by( 'id', 'desc' )-&gt;
get( 'downloads' )-&gt;result();
}</pre>
<p>Now, to actually add in the download limit, find the following piece of code in the <code>download()</code> method in the Items controller:</p>
<pre class="php">// Check purchase was fulfilled
if ( ! $purchase ) {
  $this-&gt;session-&gt;set_flashdata( 'error', 'Download key not valid.' );
  redirect( 'items' );
}
if ( $purchase-&gt;active == 0 ) {
  $this-&gt;session-&gt;set_flashdata( 'error', 'Download not active.' );
  redirect( 'items' );
}</pre>
<p>Directly after this, add the following:</p>
<p>&nbsp;</p>
<div style="width: 650px;">
<pre class="php">// Check download limit
$download_limit = $this-&gt;config-&gt;item( 'download_limit' );
if ( $download_limit['enable'] ) {
  $downloads = $this-&gt;Item-&gt;get_purchase_downloads( $purchase-&gt;id, $download_limit['downloads'] );
  $count = 0;
  $time_limit = time() - (86400 * $download_limit['days']);
  foreach ( $downloads as $download ) {
    if ( $download-&gt;download_at &gt;= $time_limit )
      $count++; // download within past x days
    else
      break; // later than x days, so can stop foreach
  }

  // If over download limit, error
  if ( $count &gt;= $download_limit['downloads'] ) { // can only download x times within y days
    $this-&gt;session-&gt;set_flashdata( 'error', 'You can only download a file ' . $download_limit['downloads'] . 
' times in a ' . $download_limit['days'] . ' day period. Please try again later.' );
    redirect( 'items' );
  }
}</pre>
</div>
<p>&nbsp;</p>
<p>On the third line we check whether the &#8216;Download Limit&#8217; functionality is enabled in the config file. If it is, we retrieve the downloads of the current purchase (limited to how many file downloads is permitted).</p>
<p>At line 6, we calculate the furthest time away downloads are limited to (eg. if we have a limit of 4 downloads in 7 days, we find the time 7 days ago) by multiplying the number of days by 86400 (the number of seconds in a day) and subtracting it from the current time.</p>
<p>The loop starting at line 7 checks each download logged to see if it was downloaded within the time limit (eg. 7 days). If it is, we increase <code>$count</code>, otherwise, we break out of the loop as we know if this logged download is older than the limit, all subsequent logs will be to.</p>
<p>At line 15, if the <code>$count</code> is greater than the number of downloads allowed, we display an error message. Otherwise, the rest of the code will be executed and the download will be logged and initiated.</p>
<div class="tutorial_image"><img src="images/download-limit.png" alt="" border="0" /></div>
<p>We&#8217;re done. Try it out!</p>
<p><strong>Note:</strong> To disable the PayPal &#8216;sandbox&#8217; mode so you can recieve real payments, change the <code>$config['paypal_lib_sandbox_mode']</code> option in <code>config/paypallib_config.php</code> to <code>false</code>.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/how-to-create-a-digital-shopping-cart-with-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Install PHP MySql Apache phpMyAdmin on Ubuntu 9.04</title>
		<link>http://redbonzai.com/how-to-install-php-mysql-apache-phpmyadmin-on-ubuntu-9-04/</link>
		<comments>http://redbonzai.com/how-to-install-php-mysql-apache-phpmyadmin-on-ubuntu-9-04/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 01:40:59 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[configure apache mysql and php on ubuntu 9.04]]></category>
		<category><![CDATA[install lamp]]></category>
		<category><![CDATA[install ubuntu 9.04]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ubuntu 9.04]]></category>
		<category><![CDATA[Web Application Development Houston Tx]]></category>
		<category><![CDATA[Web Developer Houston Tx]]></category>

		<guid isPermaLink="false">http://www.redbonzai.com/blog/?p=295</guid>
		<description><![CDATA[This is the quickest way that I know how to install PHP, MySql, Apache, and phpMyAdmin on Linux using Ubuntu 9.04.  This should literally take 15 minutes to complete. ]]></description>
			<content:encoded><![CDATA[<p class="biglines">
RedBonzai Developers, INC is a web developer in Houston, Tx dedicated to LAMP web application development.  Our web application development is centered on the LAMP stack and in specific on Ubuntu 9.04.  So, today we are giving a small tutorial on how to configuring ubuntu 9.04 with apache, mysql and PHP.  Enjoy &#8230;
</p>
<p class="biglines">Start by opening the terminal and executing the following commands: <br/><br />
<code><br />
sudo apt-get install apache2 php5 php5-mysql mysql-server<br />
</code><br />
<br/><br />
Now, test the apache by browsing to this page: http://localhost<br />
<br/> You should get the following page: </p>
<div class="note" style="width:650px;">
<div id="attachment_297" class="wp-caption alignleft" style="width: 310px"><img src="http://www.redbonzai.com/wp-content/uploads/2010/08/itworks-300x217.png" alt="RedBonzai Developers Web Developers in Houston, Tx using the LAMP stack" title="RedBonzai Developers: apache verification page for configuring apache on Linux" width="300" height="217" class="size-medium wp-image-297" />
<p class="wp-caption-text">RedBonzai Developers: Web Developers in Houston Texas Using the Lamp Stack</p>
</div>
</div>
<p><br/><br />
<!-- ADD --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, redbonzai Posts */
google_ad_slot = "2826230417";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD --><br />
At this point it is a good idea to create a phpInfo.php page.  So do this: <br/><br />
<code><br />
cd /var/www/ <br/><br />
sudo gedit phpinfo.php<br/></p>
<p></code><br />
<br/> This will open the file that you are creating ( phpinfo).  so type the following: <br/></p>
<pre class="brush:php">
&lt;?php <br/>
phpinfo();
?&#038;gt
</pre>
<p><br/> now save it and go to the following url: http://localhost/phpinfo.php.  You should get the INFO page with all that PHP has compiled. <br/><br />
Now, install phpMyAdmin: <br/></p>
<p><code>sudo apt-get install phpmyadmin</code><br/></p>
<p>After finishing, you need to execute this command below.  This  changes the phpMyadmin folder  to var/www.</p>
<p><code>sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin</code></p>
<p>Testing phpMyadmin http://localhost/phpmyadmin/index.php</p>
<p>Username for phpMyAdmin is “root”.
</p>
<p><!-- ADD 2 --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD 2 --></p>
<div class="note">
<p class="biglines">
I hope that this has been helpful to you.  Please refer readers this way, and also make suggestions, comments and requests on anything that you need help in.   I am sure that we can help you solve it.<br/><br />
Feel free to contact us using the form below, or on our contact page.
</p>
<p>[contact-form-7]
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/how-to-install-php-mysql-apache-phpmyadmin-on-ubuntu-9-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update Multiple Mysql Rows in a Single Query</title>
		<link>http://redbonzai.com/update-multiple-rows-in-a-single-query/</link>
		<comments>http://redbonzai.com/update-multiple-rows-in-a-single-query/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 15:17:36 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[MySql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[custom web Design]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php Development]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[Web application Development]]></category>

		<guid isPermaLink="false">http://www.redbonzai.com/blog/?p=257</guid>
		<description><![CDATA[Here is a smart way to update multiple database rows inside of a single SQL Query.  We are going to incorporate PHP programming to generate a dynamic MySql query that could update hundreds of rows inside of a mysql Database.]]></description>
			<content:encoded><![CDATA[<p><img src="http://redbonzai.com/wp-content/uploads/2010/08/phpCode.jpg" alt="" title="phpCode" width="625" height="400" class="alignnone size-full wp-image-381" /> </p>
<p><!-- ADD --><br />
<script type="text/javascript">
google_ad_client = "pub-7439518364115179";
/* 728x90, redbonzai Posts */
google_ad_slot = "2826230417";
google_ad_width = 600;
google_ad_height = 90;</p>
<p></script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD --></p>
<p>The first query simply updates a single column within a mysql row:</p>
<div style="width:600px;">
<pre class="brush:mysql">
UPDATE tableName SET fieldName= 'fieldValue' WHERE fieldName2= 'fieldValue2';

</pre>
</div>
<p>The last mysql statement is fantastic for a single query.  However, now suppose that we need to update multiple rows, and the field name changes in value.  Said in other words, there are different fields that require a different updated value.  Well, here is an example :</p>
<p>First, put the fields to be updated into an associative array and put it through a PHP  <code>foreach</code> loop</p>
<div style="width:600px;">
<pre class="brush:php">
<p class="biglines">
&lt;?php 
foreach ($associative_array as $field => $value) {
    $sql = "UPDATE categories SET fieldname = $value WHERE field = $field";
    mysql_query($sql);
}
?&gt;
</p>
</pre>
</div>
<p>that should work right? &#8230; &#8230; NOPE &#8230; well, why? <br/><br />
 OK &#8230; It will probably work, but one thing that you have to keep in mind is that you are pinging the database N times for N=the amount of rows that need to be updated.  What if N=1000?<br/><br />
This is saying that you have N queries to make, and what if there are are N users doing the same thing?  You are setting yourself up for a crash.  </p>
<p>Is there another way?  &#8230; YEP</p>
<div style="width:600px;">
<pre class="brush:mysql">

 UPDATE mytable
    SET fieldName= CASE other_field
        WHEN 1 THEN 'value'
        WHEN 2 THEN 'value'
        WHEN 3 THEN 'value'
        WHEN 4 THEN 'value'
    END
WHERE id IN (1,2,3, 4);

</pre>
</div>
<p>OK &#8230; we are going to apply this to a PHP script, but first let&#8217;s talk about the scenario in which multiple columns must be updated within a single MySql query: </p>
<p>So, if the CASEis the fieldname that we are checking for,  and the value of the fieldname matches the value we are checking for, then we update it to the new field value. </p>
<p>The WHERE clause  ensures that the logic is only applied to the smallest number of rows possible.  Now you can see the event in which Nis a row, and N->1000. Now see that all N rows were updated in only 1 Query.  Pretty cool</p>
<p>What about when you need to update multiple fields instead of one? We add another CASE block.</p>
<div style="width:600px;">
<pre class="brush:mysql">
UPDATE tableName
    SET fieldname1= CASE fieldValue1
        WHEN robot THEN 'voltron'
        WHEN truck THEN 'optimus Prime'
        WHEN websites THEN 'redbonzai'
        WHEN code THEN 'PHP'
    END,
    fieldname2= CASE fieldValue2
        WHEN 'clown' THEN 'Bozo'
        WHEN 'robot' THEN 'transformer'
        WHEN 'furry' THEN 'Teddy Bear'
        WHEN 'OS' THEN 'Linux'
    END
WHERE fieldValue2 IN ('clown', 'robot', 'furry', 'OS');
</p>
</pre>
</div>
<p>Alright, now back to the PHP example.  Lets turn this into a dynamic query: </p>
<div style="width:600px;">
<pre class="brush:php">

&lt;?php
 $column1 = array(    'rice' => 'wild',
     'developer' => 'php',
     'furry'=> 'teddy bear',
     'funny'=> 'comedian',
     'work'=> 'never stops',
     'money'=> 'millionaire',
     'pink'=> 'polka dots',
     'Furniture'=> 'Modern'
  );


$column2 = array(
    'rice' => 'wild',
    'developer' => 'php',
    'furry'=> 'teddy bear',
    'funny'=> 'comedian',
    'work'=> 'never stops',
    'money'=> 'millionaire',
    'pink'=> 'polka dots',
    'Furniture'=> 'Modern'
);

$fields1 = implode(',', array_keys($column1));
$fields2 = implode(',', array_keys($column2));

$sql = "UPDATE column1 SET fieldName1= CASE fieldValue ";

foreach ($column1 as $field => $value) {
     if(is_numeric($field)){$field='$field';}else {$field=$field;}
    $sql .= sprintf("WHEN %s THEN %s ", $field, $value);
    //echo $field .": ".$value."<br/>";
    if($field==end(array_keys($column1))){

       $sql .= "END WHERE fieldName1 IN ($fields1);";
        $sql .= "UPDATE column2 SET fieldName2 = CASE fieldValue2";
    }    
}
foreach($column2 as $field=>$value){
          if(is_numeric($field)){$field='$field';}else {$field=$field;}
            $sql .= sprintf("WHEN %s THEN %s ", $field, $value);
            if($field== end(array_keys($column2))){
                break 1;
            }

        }
$sql .= "END WHERE fieldName2 IN ($fields2)";
echo $sql; //I echoed this out so that you can copy and paste it into your IDE, and see how it works.  
Next step is: 

$query = mysql_query($sql) or die(mysql_error()); 
// there are much better ways to validate your query, but this article is not about PHP query validation, 
it is about a single query to update multiple rows. 

?&gt;
</pre>
</div>
<p><!-- ADD --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 600;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD --></p>
<p>Now in this particular example, only 8 rows are being updated, but 7 queries have been trimed, which is not insignificant. Apply this technique to a situation where hundreds or thousands of rows have to be updated and you can imagine the benefits it will have.  There is a down side to this &#8230; <br/><br />
I understand if you have multiple rows to update, but you are ONLY updating 2 or three columns.  <br/>The more columns you update, you have to make another <code>foreach</code> loop.<br/><br />
But in the end, you end up with a pretty nice SQL string, and only 1 Query.</p>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/update-multiple-rows-in-a-single-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using jQuery and PHP to scrape web page content</title>
		<link>http://redbonzai.com/using-jquery-and-php-to-scrape-web-page-content/</link>
		<comments>http://redbonzai.com/using-jquery-and-php-to-scrape-web-page-content/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 19:59:56 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php Development]]></category>
		<category><![CDATA[Web application Development]]></category>

		<guid isPermaLink="false">http://www.redbonzai.com/blog/?p=241</guid>
		<description><![CDATA[Here is a nice trick using AJAX methods ( the javascript is in jQuery) with PHP to scrape pages of safe domains, or from subdomains that you own. ]]></description>
			<content:encoded><![CDATA[<p><img src="http://redbonzai.com/wp-content/uploads/2010/08/jQueryPHP.jpg" alt="RedBonzai Developers Custom Web Applications in PHP and Ajax technologies make business work efficiently" title="Page scraping with PHP and Jquery" width="600" height="398" class="alignleft size-full wp-image-247" /></p>
<p><!-- ADD1 --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, redbonzai Posts */
google_ad_slot = "2826230417";
google_ad_width = 600;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD1 --></p>
<p>If you were to have a subdomain that you yourself controlled / owned and you also wanted to load content from that domain via AJAX into a page how can this be done?&#8230;. We were pondering this the other day &#8230;  As you know, ( or you should know) Javascript doesn&#8217;t allow cross domain XMLHttpRequest&#8217;s or AJAX requests (Asynchronous JavaScript and XML). There is a &#8216;dirty&#8217; way to get around this using PHP and CURL to pull the HTML of the page you want to get the content from so JavaScript thinks it&#8217;s coming from your domain. Let me just say, this isn&#8217;t an ideal solution but it&#8217;s a useful technique when executed in the right situation.  </p>
<blockquote><p>NOTE: You need to have PHP5 installed on your server in order to use the CURL module.</p>
</blockquote>
<h3>The PHP</h3>
<p>In this example we&#8217;re taking the community news section from <a href="http://smashingmagazine.com">smashingmagazine.com</a>. Firstly using PHP we use CURL to get the whole contents of the homepage. we can then specify using javascript a specific div to get as explained below.</p>
<pre class="brush: php;"> 
&lt;?php
$ch = curl_init(&amp;quot;http://www.redbonzai.com/redbonzai/about_redbonzai.php;);
$html = curl_exec($ch);
echo $html;
?>
</pre>
<h3>The JavaScript</h3>
<p>This must be the simplest couple of lines of javascript ever. You can see within the DOM ready function we&#8217;re loading the content of the div #noupesoc into #content. As simple as that. You can specify any div or element on the page and grab it using this method.</p>
<pre class="brush: jscript;"> 
 &lt; script type="text/javascript" &gt;
    $('document').ready(function() {
        $('#content').load('curl.php #main');
    });
&#038;lt/script &gt;
</pre>
<h3>The HTML</h3>
<pre class="brush: php"> 

 &lt;body&gt;
&lt;?php //include '../includes/header.php';
        $link = ' &lt;a href="http://www.redbonzai.com/blog/?p=241"&gt;Back To Tutorial&lt;/a&gt;';
        $download = "&lt;a href='redbonzai.com/demos/page-scrape/page-scrape.zip'&lt;Download The Zip&lt;/a&gt;";
        
?&gt;
&lt;h5&gt;&lt;?php echo $link." ".$download;?&gt;&lt;/h5&gt;
&lt;div id="content"&gt;&lt;img src="ajax-loader.gif" alt="Loading..." /&gt;&lt;/div&gt;

&lt;?php //include '../includes/footer.php';?&gt;

&lt;/body&gt;
</pre>
<p><!-- ADD2 --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD2 --></p>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/using-jquery-and-php-to-scrape-web-page-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Use Gravatars ( Avatars)</title>
		<link>http://redbonzai.com/how-to-use-gravatars-avatars/</link>
		<comments>http://redbonzai.com/how-to-use-gravatars-avatars/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 05:08:21 +0000</pubDate>
		<dc:creator>redbonzai</dc:creator>
				<category><![CDATA[gravatar]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[get gravatar PHP]]></category>
		<category><![CDATA[gravatar profiles]]></category>
		<category><![CDATA[php Development]]></category>
		<category><![CDATA[Web application Development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.redbonzai.com/blog/?p=183</guid>
		<description><![CDATA[This is a small tutorial on how to work with Gravatar in your PHP Web Development]]></description>
			<content:encoded><![CDATA[<h3 class="nice_titles">Creating The Email Hash</h3>
<ol>
<li><strong>Trim leading and trailing whitespace from an email address</strong></li>
<li><strong>Force all characters to lower-case</strong></li>
<li><strong>md5 hash the final string</strong></li>
</ol>
<p class="biglines">As an example, let&#8217;s say we start with &#8220;MyEmailAddress@example.com &#8221; (note the trailing space which our hypothetical user entered by mistake). If we md5 encode that string directly, we get the following (in PHP):</p>
<div style="width:650px">
<pre class="brush: php">
<code>
<p class="biglines">
echo md5( "MyEmailAddress@example.com " );
// "f9879d71855b5ff21e4963273a886bfc"</pre>
</p>
<p class="biglines">If we now run that same email address through the above process, you will see that we get a different result (again in PHP):</p>
<pre class="brush: php">$email = trim( "MyEmailAddress@example.com " ); // "MyEmailAddress@example.com"
 <p class="biglines">$email = strtolower( $email ); // "myemailaddress@example.com"
echo md5( $email );
// "0bc83cb571cd1c50ba6f3e8a78ef1346"
</p>
</code>
</pre>
</div>
<p> <!-- ADD1 --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, redbonzai Posts */
google_ad_slot = "2826230417";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD1 --></p>
<p class="biglines">This can easily be combined into a single line:</p>
<div style="width:650px;">
<pre class="brush: php"> <p class="biglines">echo md5( strtolower( trim( "MyEmailAddress@example.com " ) ) ); </p>
<p class="biglines">You can even write a trusty function and call it: <code>get_gravatar();</code><br/>
it all starts by using the principles above in PHP and do the following: <br/>
function get_gravatar($email, $default, $size="80")
{
   return '&lt;img src="http://www.gravatar.com/avatar.php?gravatar_id='.md5(strtolower(trim($email))).'<br/>
            &#038;default='.$default.'&#038;size='.$size.'&#038;rating=PG" width="'.$size.'px" height="'.$size.'px" /&gt;'; 
}
</p>
</pre>
</div>
<div class="note" style="width:700px;">
<strong>Once you have generated a consistent hash, you can then request either an image or a profile.</strong>
</div>
<h3 class="nice_titles">Next request a Gravatar Profile Using PHP</h3>
<p class="biglines"> I am going to show you how to get  Gravatar profile data as a serialized PHP string. <br/><br />
Using the steps above, I am going to create the <b>Base Request:</b> </p>
<ol>
<li>Create a valid  email hash  :
<pre class="brush: php"><code>echo md5( strtolower( trim( "MyEmailAddress@example.com " ) ) );</code> </pre>
</li>
<li>BUild the URL to request the Profile Page</li>
<li>Append <code>.PHP </code> to that URL to indicate that the results should be serialized in PHP format.</li>
</ol>
<p class="biglines"> The result should be <code> http://www.gravatar.com/205e460b479e2e5b48aec07710c08d50.php</code><br/></p>
<p>So, requesting this profile in the document should look like:<br/><br />
 <a href="http://www.gravatar.com/205e460b479e2e5b48aec07710c08d50.php"> In The Browser </a>
</p>
<p>The result is a serialized string that must be formated.  I use <a href="http://portablecontacts.net/draft-spec.html#anchor3"> PortableContact.net</a> .  Feel free to check it out.</p>
<h4>An Example of the Gravatar Profile Request</h4>
<p>This example (written in PHP, and assuming you can <code>file_get_contents()</code>) just loads up my profile in serialized PHP, then unserializes it and outputs my name:</p>
<pre class="brush: php"> 
<p class="biglines">
	&lt;?php
 
	$str = file_get_contents( 'http://www.gravatar.com/205e460b479e2e5b48aec07710c08d50.php' );
	$profile = unserialize( $str );
	if ( is_array( $profile ) &#038;&#038; isset( $profile['entry'] ) )
		echo $profile['entry'][0]['displayName'];
 
	?&gt;
</p>
</pre>
<p><!-- ADD2 --><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7439518364115179";
/* 728x90, RedBonzai posts 2 */
google_ad_slot = "8798977545";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- END ADD2 --></p>
<div class="note" style="width:650px;">
I hope that this post was useful to you.  Feel free to contact me for any reason regarding PHP, MySQl, AJAX, WordPress Development or anything cool.  Give me a reason to take on a new Web Development project.
</div>
]]></content:encoded>
			<wfw:commentRss>http://redbonzai.com/how-to-use-gravatars-avatars/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
