<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.3" -->
<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/"
	>

<channel>
	<title>ajaXray</title>
	<link>http://www.ajaxray.com/blog</link>
	<description>Let\\\'s explore the web technologies together.</description>
	<pubDate>Sat, 05 Jul 2008 19:44:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>
	<language>en</language>
			<item>
		<title>Developing web application with PHP-MySql-Apache in Ubuntu Linux</title>
		<link>http://www.ajaxray.com/blog/2008/07/05/developing-web-application-with-php-mysql-apache-in-ubuntu-linux/</link>
		<comments>http://www.ajaxray.com/blog/2008/07/05/developing-web-application-with-php-mysql-apache-in-ubuntu-linux/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 19:33:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[tools]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2008/07/05/developing-web-application-with-php-mysql-apache-in-ubuntu-linux/</guid>
		<description><![CDATA[I have started using Ubuntu 8.04 in few days ago and found it Great.  So, now I&#8217;ve moved my development environment from windows and working  in Ubuntu. Here I am just explaining what steps I had to take for this jump. Also have a listing of some development related softwares/tools which I am [...]]]></description>
			<content:encoded><![CDATA[<p>I have started using Ubuntu 8.04 in few days ago and found it Great.  So, now I&#8217;ve moved my development environment from windows and working  in Ubuntu. Here I am just explaining what steps I had to take for this jump. Also have a listing of some development related softwares/tools which I am using as replacement of windows applications.</p>
<h2>Installing Apache, Php5, MySql in Ubuntu:</h2>
<p>You can install Apache, Php, Mysql and other  applications from <em>Synaptic Package Manager.</em><span style="font-style: normal"> Go to </span><span style="font-style: normal"><u>System &gt; Administration &gt;  Synaptic Package Manager</u></span><span style="font-style: normal"><span style="text-decoration: none"> and search with your desired application name. When found, double-click on package name. The package will be marked for installation along with it&#8217;s dependences. Now click on apply button to install the package. In this post, the </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>red+bold</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">  texts are the name of software package which can be installed from  Synaptic Package Manager.</span></span></p>
<p><span style="font-style: normal"><span style="text-decoration: none">To make your system ready for PHP development, you have to install more or less this packages:  </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>apache2.2-common</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">, </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>apache2-utils</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">,  </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>php5</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">, </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>mysql-server-5.0</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">,  </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>mysql-client-5.0</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">, </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>mysql-query-browser</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none"> etc. You may also require some common php extensions which may not installed automatically with PHP installation. Most of them also will be found in Synaptic Package Manager as </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>php5-gd</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">, </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>php5-curl</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">, </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>php5-mysql</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none">, </span></span><font color="#ff0000"><span style="font-style: normal"><span style="text-decoration: none"><strong>php-pear</strong></span></span></font><span style="font-style: normal"><span style="text-decoration: none"> etc.</span></span></p>
<h2 class="western">Paths of important directories</h2>
<p>One of the major differences I find here is the file system. All the directory paths I&#8217;ve been using in windows are changed here. I m listing here some PHP-MySql related paths here. But they may differ on your installation.</p>
<ul>
<li>Apache configation files: /etc/apache2/</li>
<li>localhost root directory: /var/www/</li>
<li>PHP ini file: /etc/php5/apache2/</li>
<li>PHP extensions configuration files : /etc/php5/conf.d</li>
<li>MySql Data files: /var/lib/mysql/mysql</li>
<li>MySql Configuration files:  /etc/mysql/</li>
</ul>
<h2>PHP Editors for Ubuntu</h2>
<p><font color="#ff0000"><strong>Gedit</strong></font> is the default text editor of Ubuntu and it support syntax coloring for many languages including PHP. But If you want an advanced editor for programming, you can try <font color="#ff0000"><strong>Geany</strong></font> or <font color="#ff0000"><strong>Screem</strong></font>. But, I am sure,  who&#8217;ve been using advanced IDEs like PHPEd or PHPDesigner in windows, none of this can satisfy him. Don&#8217;t worry, the great open source IDE <a href="http://www.eclipse.org/" target="_blank">eclips</a> has  <a href="http://www.eclipse.org/downloads/download.php?file=/tools/pdt/downloads/drops/R20080603/all-in-one/pdt-all-in-one-R20080603-linux-gtk.tar.gz" target="_blank">PHP-Development-Tool</a>. It&#8217;s surely one of the best PHP IDE.</p>
<h2 class="western">Subversion in  Ubuntu</h2>
<p><font color="#000000"><span>Subversion maintains current and historical versions of </span></font><a href="http://en.wikipedia.org/wiki/Source_code">source code</a><font color="#000000"><span> and documentation. It&#8217;s very important for distributed application development.</span></font><font color="#ff0000"><strong> RapidSVN</strong></font> is a graphical client for the subversion revision control system (svn) for linux.  If you want to use svn from command line, install <font color="#ff0000"><strong>subversion</strong></font><font color="#000000"><span>.</span></font></p>
<h2>File Difference and Merging Tools for Ubuntu</h2>
<p>I have been using <a href="http://winmerge.org/" target="_blank">WinMerge</a> in windows as file comparison and merging tool along with TortoiseSVN. Now using <font color="#ff0000"><strong>TkDiff</strong></font> as it&#8217;s alternative in linux. TkDiff has advanced functionalities and graphical interface. It provides file-merge and change-summary facilities, line number toggling (for easier cut &amp; paste) and support for Subversion, RCS, CVS and SCCS. To use from command line, <font color="#ff0000"><strong>diff</strong></font> is may be the simplest file comparison tool.</p>
<h2>Ftp and SSH</h2>
<p>Ubuntu installs its default programs for FTP, SSH and many other internet applications. But, I&#8217;ve liked <font color="#ff0000"><strong>gFTP</strong></font> as FTP application because of it&#8217;s interface is similar to SmartFTP. And for working with SSH, required nothing. Just open the terminal and use <font face="Tlwg Typist"><strong><span style="background: transparent none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">ssh</span></strong></font> command. Write something like <font face="Tlwg Typist"><strong><span style="background: transparent none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">ssh username@example.com</span></strong></font><font face="Tlwg Typist"><span style="background: transparent none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"> </span></font>and press ENTER.</p>
<h2>Testing in IE</h2>
<p>One of the important (and painful to me) issue of web development is testing the output in IE. Though IE has no version for Linux, you can install it through <strong>wine.</strong><span> Wine is a application that crates a virtual environment for installing windows applications in Linux. After installing wine, you can install any available version of IE from <a href="http://www.tatanka.com.br/ies4linux/page/Installation:Ubuntu" target="_blank">http://www.tatanka.com.br/ies4linux/page/Installation:Ubuntu.</a></span></p>
<p>When witting this post, my aim was to help a developer who is thinking to switch to Ubuntu Linux or a newcomer here. You are welcome to add your valuable comment/suggestion for the same purpose.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2008/07/05/developing-web-application-with-php-mysql-apache-in-ubuntu-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Universal Feed Parser - lightweight PHP class for parsing RSS and ATOM feeds.</title>
		<link>http://www.ajaxray.com/blog/2008/05/02/php-universal-feed-parser-lightweight-php-class-for-parsing-rss-and-atom-feeds/</link>
		<comments>http://www.ajaxray.com/blog/2008/05/02/php-universal-feed-parser-lightweight-php-class-for-parsing-rss-and-atom-feeds/#comments</comments>
		<pubDate>Fri, 02 May 2008 18:52:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[rss]]></category>

		<category><![CDATA[feed]]></category>

		<category><![CDATA[tools]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2008/05/02/php-universal-feed-parser-lightweight-php-class-for-parsing-rss-and-atom-feeds/</guid>
		<description><![CDATA[After the PHP Universal Feed Generator, I&#8217;ve written the PHP Universal Feed Parser for Orchid Framework.  It&#8217;s a RSS and ATOM parser written in PHP5. Though there are many feed parsers  over Internet, none of those was serving the basic focuses of Orchid: pure object orientation, being lightweight etc. So, I had to [...]]]></description>
			<content:encoded><![CDATA[<p>After the <a title="PHP Universal Feed Generator" href="http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/" target="_blank">PHP Universal Feed Generator</a>, I&#8217;ve written the<strong> PHP Universal Feed Parser</strong> for <a title="Orchid Framework" href="http://orchid.phpxperts.net/" target="_blank">Orchid Framework</a>.  It&#8217;s a RSS and ATOM parser written in PHP5. Though there are many feed parsers  over Internet, none of those was serving the basic focuses of Orchid: pure object orientation, being lightweight etc. So, I had to write a new one. </p>
<p><font color="#ff0000"><u><strong>UPDATE(15th May, 2008) :</strong></u> </font><font color="#000000"><a title="PHP cURL functions" href="http://www.php.net/curl" target="_blank">cURL</a> support added. Where url fopen() is disabled, the class will use cURL to load the RSS/ATOM content.</font></p>
<p><strong><u>Features:</u> </strong> </p>
<ul>
<li>Parses all channels and feed item tags and sub tags. </li>
<li>Serve the parsed data as associative array. </li>
<li>Enough documented and easy to understand code. </li>
<li>Many ways to get parsed information.  </li>
<li>Parsing includes attributes too. </li>
<li>No regular expression used. </li>
<li>Parsed by <strong><a title="XML Parser Functions" href="http://www.php.net/xml" target="_blank">XML Parser</a></strong> extension of PHP. </li>
<li>Pure PHP5 objected oriented. </li>
<li>Enable to parse all commonly used feed versions. </li>
</ul>
<p><strong><u>Supported versions:</u> </strong>I tried to include all stable and commonly used feed versions. Currently it&#8217;s being used to parse the following versions:</p>
<ul>
<li><strong>RSS 1.0</strong>  </li>
<li><strong>RSS 2.0</strong> </li>
<li><strong>ATOM 1.0</strong> </li>
</ul>
<p><u><strong>Download:</strong></u></p>
<ul>
<li>Click <a title="Download FeedParser" href="http://www.ajaxray.com/blog/downloads/feedparser" target="_blank">Here</a> to get the  class file with example. (downloaded 481 times) </li>
<li>Download  from <a title="PHP Universal Feed Parser at www.phpclasses.org" href="http://www.phpclasses.org/browse/package/4548.html" target="_blank">phpclasses.org</a>. </li>
</ul>
<p><strong><u>How to use:</u></strong></p>
<p>It&#8217;s dead simple to use this class. Just follow this 3 steps: </p>
<p>1. Include the file </p>
<p>    include(&#8217;FeedParser.php&#8217;); </p>
<p>2. Create an object of FeedParser class </p>
<p>    $Parser = new FeedParser(); </p>
<p>3. Parse the URL you want to featch </p>
<p>    $Parser-&gt;parse(&#8217;http://www.sitepoint.com/rss.php&#8217;); </p>
<p>Done. </p>
<p>Now you can use this functions to get various information of parsed feed:</p>
<ul>
<li>$Parser-&gt;getChannels()          - To get all channel elements as array </li>
<li>$Parser-&gt;getItems()               - To get all feed elements as array </li>
<li>$Parser-&gt;getChannel($name)   - To get a channel element by name </li>
<li>$Parser-&gt;getItem($index)       - To get a feed element as array by it&#8217;s index </li>
<li>$Parser-&gt;getTotalItems()        - To get the number of total feed elements </li>
<li>$Parser-&gt;getFeedVersion()     - To get the detected version of parsed feed </li>
<li>$Parser-&gt;getParsedUrl()         - To get the parsed feed URL </li>
</ul>
<p><u><strong>A simple example:</strong></u></p>
<p>Here is a simple example of using this Feed Parser class.  <a title="example output of FeedParser php class" href="http://www.ajaxray.com/projects/rss/" target="_blank">Click here</a> to see is the output of this example.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">php</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #ff0000">include</span>(<span style="color: #0000ff">&#8216;FeedParser.php&#8217;</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$<span style="color: #ff0000">Parser</span>     = <span style="color: #ff0000">new</span> <span style="color: #ff0000">FeedParser</span>();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$<span style="color: #ff0000">Parser-</span><span style="color: #0000ff">&gt;</span>parse(&#8217;http://www.sitepoint.com/rss.php&#8217;);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">$channels   = $Parser-<span style="color: #0000ff">&gt;</span>getChannels();     </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">$items      = $Parser-<span style="color: #0000ff">&gt;</span>getItems();        </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">?<span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">h1</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&#8221;title&#8221;</span><span style="color: #0000ff">&gt;&lt;</span><span style="color: #800000">a</span> <span style="color: #ff0000">href</span>=&#8221;&lt;?<span style="color: #ff0000">php</span> <span style="color: #ff0000">echo</span> $<span style="color: #ff0000">channels</span>[<span style="color: #0000ff">&#8216;LINK&#8217;</span>]; ?<span style="color: #0000ff">&gt;</span>&#8220;<span style="color: #0000ff">&gt;&lt;?</span><span style="color: #800000">php</span> <span style="color: #ff0000">echo</span> $<span style="color: #ff0000">channels</span>[<span style="color: #0000ff">&#8216;TITLE&#8217;</span>]; ?<span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">a</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">h1</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&#8221;description&#8221;</span><span style="color: #0000ff">&gt;&lt;?</span><span style="color: #800000">php</span> <span style="color: #ff0000">echo</span> $<span style="color: #ff0000">channels</span>[<span style="color: #0000ff">&#8216;DESCRIPTION&#8217;</span>]; ?<span style="color: #0000ff">&gt;</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">php</span> <span style="color: #ff0000">foreach</span>($<span style="color: #ff0000">items</span> <span style="color: #ff0000">as</span> $<span style="color: #ff0000">item</span>)<span style="color: #ff0000">:</span> ?<span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">a</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8221;feed-title&#8221;</span> <span style="color: #ff0000">href</span>=&#8221;&lt;?<span style="color: #ff0000">php</span> <span style="color: #ff0000">echo</span> $<span style="color: #ff0000">item</span>[<span style="color: #0000ff">&#8216;LINK&#8217;</span>]; ?<span style="color: #0000ff">&gt;</span>&#8220;<span style="color: #0000ff">&gt;&lt;?</span><span style="color: #800000">php</span> <span style="color: #ff0000">echo</span> $<span style="color: #ff0000">item</span>[<span style="color: #0000ff">&#8216;TITLE&#8217;</span>]; ?<span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">a</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">&lt;</span><span style="color: #800000">p</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&#8221;feed-description&#8221;</span><span style="color: #0000ff">&gt;&lt;?</span><span style="color: #800000">php</span> <span style="color: #ff0000">echo</span> $<span style="color: #ff0000">item</span>[<span style="color: #0000ff">&#8216;DESCRIPTION&#8217;</span>]; ?<span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">p</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;?</span><span style="color: #800000">php</span> <span style="color: #ff0000">endforeach</span>;?<span style="color: #0000ff">&gt;</span></pre>
</p>
</div>
</div>
<p>I hope, this class is so easy that, anyone who have general knowledge about PHP5 can use it. Whatever it is, Feel free to ask me anything, anytime.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2008/05/02/php-universal-feed-parser-lightweight-php-class-for-parsing-rss-and-atom-feeds/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Universal Feed Generator (supports RSS 1.0, RSS 2.0 and ATOM)</title>
		<link>http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/</link>
		<comments>http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 19:47:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ATOM]]></category>

		<category><![CDATA[writer]]></category>

		<category><![CDATA[rss]]></category>

		<category><![CDATA[feed]]></category>

		<category><![CDATA[tools]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve planned on developing a RSS writer that fulfills most my needs by supporting the various feed formats. Although the necessity was the prime force behind it, a discussion with Hasin and Emran has put the actual fire in. We were discussing about what can be added next in the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve planned on developing a RSS writer that fulfills most my needs by supporting the various feed formats. Although the necessity was the prime force behind it, a discussion with <a href="http://hasin.wordpress.com" target="_blank">Hasin</a> and <a href="http://www.phpfour.com/blog" target="_blank">Emran</a> has put the actual fire in. We were discussing about what can be added next in the <a href="http://www.orchidframework.net/">Orchid - &#8220;PHP framework for the rest of us&#8221;</a> and suddenly it hit me. At last, it&#8217;s finally complete and I&#8217;ve named it &quot;<strong>PHP Universal Feed Generator</strong>&quot;, as it generates both ATOM and RSS feeds.</p>
<p><strong><u>Supported versions:</u></strong> </p>
<ul>
<li><strong>RSS 1.0</strong> (which officially obsoleted RSS 0.90) </li>
<li><strong>RSS 2.0</strong> (which officially obsoleted RSS 0.91, 0.92, 0.93 and 0.94) </li>
<li><strong>ATOM 1.0</strong> </li>
</ul>
<p><strong><u>Download:</u></strong>&#160; </p>
<ul>
<li>Download it from <a href="http://www.ajaxray.com/blog/downloads/feedwriter" target="_blank">here</a> (downloaded 2510 times). </li>
<li>Download from <a href="http://www.phpclasses.org/browse/package/4427.html" target="_blank">phpclasses.org</a>. </li>
</ul>
<p><strong><u>Features:</u></strong></p>
<ul>
<li>Generates RSS 1.0, RSS 2.0 and ATOM 1.0 feeds </li>
<li>All feeds are are validated by <a href="http://feedvalidator.org/" target="_blank">feed validator</a>. </li>
<li>Supports all possible feed elements. </li>
<li>Simple and easy to define channel and feed items </li>
<li>Implements appropriate namespaces for different versions. </li>
<li>Automatically converts date formats. </li>
<li>Generates <a href="http://www.ajaxray.com/blog/2008/02/06/php-uuid-generator-function/" target="_blank">UUID</a> for ATOM feeds. </li>
<li>Enables usage of subtags and attributes. (example: image and encloser tags) </li>
<li>Completely Object oriented in PHP5 class structure. </li>
<li>Handles CDATA encoding for required tags. </li>
<li>Nearly same code for generating all kinds of feed </li>
</ul>
<p><strong><u>A minimum example</u></strong></p>
<p>It&#8217;s a minimum example of using this class. I am generating a RSS 2.0 feed from retrieved data from a MySQL database. There are more examples in the download package for different versions.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 95.33%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; height: 235px; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&lt;?php</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">// This is a minimum example of using the Universal Feed Generator Class</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  include(<span style="color: #006080">&quot;FeedWriter.php&quot;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  <span style="color: #008000">//Creating an instance of FeedWriter class. </span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  $TestFeed = <span style="color: #0000ff">new</span> FeedWriter(RSS2);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">//Setting the channel elements</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  <span style="color: #008000">//Use wrapper functions for common channel elements</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  $TestFeed-&gt;setTitle(<span style="color: #006080">&#8216;Testing &amp; Checking the RSS writer class&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  $TestFeed-&gt;setLink(<span style="color: #006080">&#8216;http://www.ajaxray.com/projects/rss&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  $TestFeed-&gt;setDescription(<span style="color: #006080">&#8216;This is test of creating a RSS 2.0 feed Universal Feed Writer&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">//Image title and link must match with the &#8216;title&#8217; and &#8216;link&#8217; channel elements for valid RSS 2.0</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  $TestFeed-&gt;setImage(<span style="color: #006080">&#8216;Testing the RSS writer class&#8217;</span>,<span style="color: #006080">&#8216;http://www.ajaxray.com/projects/rss&#8217;</span>,<span style="color: #006080">&#8216;http://www.rightbrainsolution.com/images/logo.gif&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">//Retriving informations from database</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    mysql_connect(&quot;server&quot;, &quot;mysql_user&quot;, &quot;mysql_password&quot;);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    mysql_select_db(&quot;my_database&quot;);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">

&#160;&#160;&#160; $result = mysql_query(&quot;Your query here&quot;);

&#160;
</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">while</span>($row = mysql_fetch_array($result, MYSQL_ASSOC))</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #008000">//Create an empty FeedItem</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        $newItem = $TestFeed-&gt;createNewItem();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//Add elements to the feed item    </span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        $newItem-&gt;setTitle($row[<span style="color: #006080">&#8216;title&#8217;</span>]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        $newItem-&gt;setLink($row[<span style="color: #006080">&#8216;link&#8217;</span>]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        $newItem-&gt;setDate($row[<span style="color: #006080">&#8216;create_date&#8217;</span>]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        $newItem-&gt;setDescription($row[<span style="color: #006080">&#8216;description&#8217;</span>]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//Now add the feed item</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        $TestFeed-&gt;addItem($newItem);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">//OK. Everything is done. Now genarate the feed.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  $TestFeed-&gt;genarateFeed();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">?&gt;</pre>
</p></div>
</div>
<p>Shhhh&#8230;.a universal feed reader is on the way <img src='http://www.ajaxray.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP UUID generator function</title>
		<link>http://www.ajaxray.com/blog/2008/02/06/php-uuid-generator-function/</link>
		<comments>http://www.ajaxray.com/blog/2008/02/06/php-uuid-generator-function/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 19:40:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[snippet]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2008/02/06/php-uuid-generator-function/</guid>
		<description><![CDATA[Universally Unique Identifier is an identifier standard which is used in a varieties of software construction. When I was writing the RSS Writer class for Orchid, I needed to generate UUID to implement with ATOM id. I searched the web for a simple solution, but didn&#8217;t find any that suffices my need. Then I wrote [...]]]></description>
			<content:encoded><![CDATA[<p><b>Universally Unique Identifier</b> is an identifier standard which is used in a varieties of software construction. When I was writing the RSS Writer class for <a title="Orchid : Open source PHP framework" href="http://orchid.phpxperts.net/" target="_blank">Orchid</a>, I needed to generate UUID to implement with ATOM id. I searched the web for a simple solution, but didn&#8217;t find any that suffices my need. Then I wrote the following function to generate it. I&#8217;ve use the standard of <a href="http://en.wikipedia.org/wiki/Canonical#Computer_science">canonical</a> format here. </p>
<p>Let&#8217;s take a look what Wikipedia has to say about the format of UUID :</p>
<blockquote><p>A UUID is a 16-byte (128-bit) number. The number of theoretically possible UUIDs is therefore 216*8 = 2128 = 25616 or about 3.4 &#215; 1038. This means that 1 trillion UUIDs would have to be created every nanosecond for 10 billion years to exhaust the number of UUIDs. </p>
<p>In its canonical form, a UUID consists of 32 hexadecimal digits, displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.</p>
</blockquote>
<p>Enough said. Here is the function. </p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">/**</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">  * Generates an UUID</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">  * </span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">  * @author     Anis uddin Ahmad &lt;admin@ajaxray.com&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">  * @param      string  an optional prefix</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">  * @return     string  the formatted uuid</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">  */</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #0000ff">function</span> uuid($prefix = <span style="color: #006080">&#8221;</span>) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    $chars = md5(uniqid(rand()));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $uuid  = substr($chars,0,8) . <span style="color: #006080">&#8216;-&#8217;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    $uuid .= substr($chars,8,4) . <span style="color: #006080">&#8216;-&#8217;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $uuid .= substr($chars,12,4) . <span style="color: #006080">&#8216;-&#8217;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    $uuid .= substr($chars,16,4) . <span style="color: #006080">&#8216;-&#8217;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    $uuid .= substr($chars,20,12);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">return</span> $prefix . $uuid;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  }</pre>
</p></div>
</div>
<p>Example of using the function -</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">//Using without prefix.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">echo uuid(); <span style="color: #008000">//Returns like &#8216;1225c695-cfb8-4ebb-aaaa-80da344e8352&#8242; </span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">//Using with prefix</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">echo uuid(&#8216;urn:uuid:&#8217;);<span style="color: #008000">//Returns like &#8216;urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344e8352&#8242;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>
</p></div>
</div>
<p>See you.</p>
<p><strong>UPDATE : The <font color="#ff0000"><a title="A PHP class for generating valid RSS and ATOM feed." href="http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/" target="_blank">PHP Universal Feed Generator</a></font> class, for which I wrote this function is released.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2008/02/06/php-uuid-generator-function/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to avoid POSTDATA resend warning</title>
		<link>http://www.ajaxray.com/blog/2008/01/12/how-to-avoid-postdata-resend-warning/</link>
		<comments>http://www.ajaxray.com/blog/2008/01/12/how-to-avoid-postdata-resend-warning/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 09:52:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2008/01/12/how-to-avoid-postdata-resend-warning/</guid>
		<description><![CDATA[&#34;POSTDATA resend&#34; warning is a common problem when developing web applications. Before discussing about the solution, let&#8217;s know what is the problem actually and when it arises. 
About the problem :
We see this warning when we try to revisit a page that has accepted POSTDATA using browser&#8217;s history mechanism. Usually we do it by browser&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>&quot;POSTDATA resend&quot; warning is a common problem when developing web applications. Before discussing about the solution, let&#8217;s know what is the problem actually and when it arises. </p>
<h4><u><strong><font color="#ff0000">About the problem :</font></strong></u></h4>
<p>We see this warning when we try to revisit a page that has accepted POSTDATA using browser&#8217;s history mechanism. Usually we do it by browser&#8217;s BACK button or refreshing a page. When a page in browser history requested with POST method, the browser thinks this POSTDATA is important to process this page. So, it asks the user if he wants to send the POSTDATA again or not. Different browsers show this warning differently. For example, the images below shows how Firefox and Internet Explorer show this warning.</p>
<table cellspacing="0" cellpadding="2" width="400" border="0">
<tbody>
<tr>
<td valign="top" width="400"><a href="http://www.ajaxray.com/blog/wp-content/uploads/2008/01/postdata-resend-mozilla.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="140" alt="POSTDATA_resend_mozilla" src="http://www.ajaxray.com/blog/wp-content/uploads/2008/01/postdata-resend-mozilla-thumb.jpg" width="493" border="0" /></a></td>
</tr>
<tr>
<td valign="top" width="400">
<p align="center"><strong>POSTDATA resend warning in Mozilla Firefox</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="400">
<p align="center"><a href="http://www.ajaxray.com/blog/wp-content/uploads/2008/01/postdata-resend-ie.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="202" alt="POSTDATA_resend_ie" src="http://www.ajaxray.com/blog/wp-content/uploads/2008/01/postdata-resend-ie-thumb.jpg" width="376" border="0" /></a> </p>
</td>
</tr>
<tr>
<td valign="top" width="400">
<p align="center"><strong>POSTDATA resend warning in Internet Explorer</strong> </p>
</td>
</tr>
</tbody>
</table>
<p>&#160; </p>
<p>Now, If the user accepts the confirmation, the page is reloaded with previously sent data using POST method; otherwise some browsers don&#8217;t take any action and some shows a &quot;<strong>Webpage has expired</strong>&quot; message. In some situations, this re-submitting is useful, but most of the times it&#8217;s not expected. It&#8217;s more harmful when user accepts it without understanding and causes multiple entries of previously entered data in database. </p>
<h4><strong><u><font color="#ff0000">The easy solution :</font></u></strong></h4>
<p>The easy solution is simply redirecting. When we redirect a page, the target page is loaded without any POST data that comes with request. </p>
<p>Let&#8217;s solve this problem by hand. Say we have 2 pages - A and B. A has a feedback form which submits data by POST request method to B. B inserts the information into database and shows a success message. </p>
<p>Now, if the user try to reload the page by refresh, back button or any other way, browser will show the confirmation message. If user accepts this, the message will inserted again. But after inserting to database, If we redirect to another page C and C shows the success message, the problem will not occur. Because, in the final output to the browser will come from C which didn&#8217;t use any POST request data. The code should be something like this:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&lt;?php</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">if</span>($_POST)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">/* Form validation, Inserting to database or anything you want goes here */</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">/* Now redirect to another page */</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  header(<span style="color: #006080">&#8216;Location: http://yoursite.com/success.php&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">?&gt;</pre>
</p></div>
</div>
<p>&#160;</p>
<h4><strong><u><font color="#ff0000">Extending the solution :</font></u></strong></h4>
<p>The solution I explained above can show just an static message like &quot;Thanks for your feedback&quot; or &quot;Registration completed successfully&quot; etc. But usually we like to include some information about sender or submitted information in the success of failure message. For example:</p>
<blockquote>
<p>Hi <strong><font color="#800080">Andrew</font></strong>, your registration is successfully completed. An email is sent to you at <font color="#800080"><strong>andy001@yahoo.com</strong></font> with more information. </p>
</blockquote>
<p>In the above message, the purple colored information has to be taken from POST data. But the POST data will be lost when redirecting. So, it&#8217;s not possible by the above solution. </p>
<p>What we can do to solve this is that we can use SESSION to store those data which we want to display with message in redirected page. Just like this:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&lt;?php</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">session_start();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">if</span>($_POST)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">/* Form validatio, Inserting to database or anything you want goes here */</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">//Store data to session</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  $_SESSION[<span style="color: #006080">&#8216;name&#8217;</span>]   = $_POST[<span style="color: #006080">&#8216;name&#8217;</span>];</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  $_SESSION[<span style="color: #006080">&#8216;email&#8217;</span>]  = $_POST[<span style="color: #006080">&#8216;email&#8217;</span>];</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">  <span style="color: #008000">//Now redirect to another page </span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">  header(<span style="color: #006080">&#8216;Location: http://yoursite.com/success.php&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">?&gt;</pre>
</p></div>
</div>
<div>&#160;</div>
<div>In the target page, when showing the success message, we can get the information from SESSION easily. </div>
<div>&#160;</div>
<div>Hope this will solve your problem. Please tell me if any confusion or question with this article.&#160; See you again.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2008/01/12/how-to-avoid-postdata-resend-warning/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interactive character limit for textarea using Jquery</title>
		<link>http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/</link>
		<comments>http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 19:35:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[Jquery]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/</guid>
		<description><![CDATA[For a textbox, character of a field can easily be limited with maxlength attribute. But maxlength doesn&#8217;t work for&#xA0; a textarea. So, It needs an alternate way. For one of my project, I wrote a function for this purpose where I used jQuery. Here I am explaining how I did it. 
Let&#8217;s look an example [...]]]></description>
			<content:encoded><![CDATA[<p>For a textbox, character of a field can easily be limited with maxlength attribute. But maxlength doesn&#8217;t work for&#xA0; a textarea. So, It needs an alternate way. For one of my project, I wrote a function for this purpose where I used <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a>. Here I am explaining how I did it. </p>
<p>Let&#8217;s look an example of this interactive solution <a title="textarea character limit example" href="http://www.ajaxray.com/Examples/charLimit.html" target="_blank">here</a>.&#xA0; </p>
<p>OK. Now we will make this in 2 easy steps.</p>
<p>1. Import your jQuery file and write the function &quot;limitChars(textid, limit, infodiv)&quot; in the head section of your page.</p>
<p>This function takes 3 parameters. They are:</p>
<ul>
<li>textid : (string) The ID of your textarea. </li>
<li>limit : (num) The number of character you allow to write. </li>
<li>infodiv : (string) The ID of a div, in which limit information will be shown . </li>
</ul>
<p>&#xA0; Here is the function:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> &lt;script language=<span style="color: #006080">&quot;javascript&quot;</span> src=<span style="color: #006080">&quot;Jquery.js&quot;</span>&gt;&lt;/script&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> &lt;script language=<span style="color: #006080">&quot;javascript&quot;</span>&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 3:</span> <span style="color: #0000ff">function</span> limitChars(textid, limit, infodiv)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 4:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 5:</span> <span style="color: #0000ff">var</span> text = $(<span style="color: #006080">&#8216;#&#8217;</span>+textid).val(); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 6:</span> <span style="color: #0000ff">var</span> textlength = text.length;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 7:</span> <span style="color: #0000ff">if</span>(textlength &gt; limit)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 8:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 9:</span> $(<span style="color: #006080">&#8216;#&#8217;</span> + infodiv).html(<span style="color: #006080">&#8216;You cannot write more then &#8216;</span>+limit+<span style="color: #006080">&#8216; characters!&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 10:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+textid).val(text.substr(0,limit));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 11:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 12:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 13:</span> <span style="color: #0000ff">else</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 14:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 15:</span> $(<span style="color: #006080">&#8216;#&#8217;</span> + infodiv).html(<span style="color: #006080">&#8216;You have &#8216;</span>+ (limit - textlength) +<span style="color: #006080">&#8216; characters left.&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 16:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 17:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 18:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 19:</span> &lt;/script&gt;</pre>
</p></div>
</div>
<div>Remember, the script is using jQuery. So be careful about the path of jquery at first line of this script.</div>
<div>&#xA0;</div>
<div>2. Bind the function to the keyup event of your textarea. Do this in jQuery&#8217;s ready event of document. Just like this:</div>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> $(<span style="color: #0000ff">function</span>(){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> $(<span style="color: #006080">&#8216;#comment&#8217;</span>).keyup(<span style="color: #0000ff">function</span>(){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 3:</span> limitChars(<span style="color: #006080">&#8216;comment&#8217;</span>, 20, <span style="color: #006080">&#8216;charlimitinfo&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 4:</span> })</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 5:</span> });</pre>
</p></div>
</div>
<div>Here my textarea&#8217;s id is &#8216;comment&#8217; , limit of characters is 20 and limit information will shown in a div whose id is &#8216;charlimitinfo&#8217;. That&#8217;s all, we have made an &quot;Interactive character limiter&quot; for our textarea using Jquery. </div>
<div>&#xA0;</div>
<div><strong><font color="#ff0000">If you are not using jQuery</font></strong> for your site, it will not be wise to include it only for this script. You can get the same functionality from javascript without jquery. Look at <a title="textarea character limit example" href="http://www.ajaxray.com/Examples/charLimit2.html" target="_blank">this example</a>. It looks like and works 100% as the previous though not using jquery.</div>
<div>Here you need just 2 changes. First, change the function &quot;limitChars&quot; as follows :</div>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> <span style="color: #0000ff">function</span> limitChars(textarea, limit, infodiv)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 3:</span> <span style="color: #0000ff">var</span> text = textarea.value; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 4:</span> <span style="color: #0000ff">var</span> textlength = text.length;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 5:</span> <span style="color: #0000ff">var</span> info = document.getElementById(infodiv);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 6:</span>&#xA0; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 7:</span> <span style="color: #0000ff">if</span>(textlength &gt; limit)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 8:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 9:</span> info.innerHTML = <span style="color: #006080">&#8216;You cannot write more then &#8216;</span>+limit+<span style="color: #006080">&#8216; characters!&#8217;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 10:</span> textarea.value = text.substr(0,limit);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 11:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 12:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 13:</span> <span style="color: #0000ff">else</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 14:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 15:</span> info.innerHTML = <span style="color: #006080">&#8216;You have &#8216;</span>+ (limit - textlength) +<span style="color: #006080">&#8216; characters left.&#8217;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 16:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 17:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 18:</span> }</pre>
</p></div>
</div>
<div>&#xA0;</div>
<div>And finally, call the function manually on keyup event of your textarea. Use &quot;this&quot; keyword for textarea instead of id when calling the function. example:</div>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">textarea</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;comment&quot;</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">=&quot;comment&quot;</span> <span style="color: #ff0000">onkeyup</span><span style="color: #0000ff">=&quot;limitChars(this, 20, &#8216;charlimitinfo&#8217;)&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">textarea</span><span style="color: #0000ff">&gt;</span></pre>
</p></div>
</div>
<div>Finished. We made the solution again without dependency of any javascript framework.</div>
<p>Please let me know if you have an idea to make it better.&#xA0; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2007/11/09/interactive-character-limit-for-textarea-using-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery controlled Dependent (or Cascading) Select List 2</title>
		<link>http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/</link>
		<comments>http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 06:40:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[Jquery]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/</guid>
		<description><![CDATA[Thank you all. Thanx for using, commenting and visiting my script jQuery controlled Dependent (or Cascading) Select List from my old bolg http://php4bd.wordpress.com and here. 
I am getting a lots of request and questions from visitors about adding some features and some other problems. Sometimes I faced some problem when using this script myself. So, [...]]]></description>
			<content:encoded><![CDATA[<p>Thank you all. Thanx for using, commenting and visiting my script <a title="Previous version" href="http://php4bd.wordpress.com/2007/07/15/javascript-controlled-dependent-or-cascading-select-list/" target="_blank">jQuery controlled Dependent (or Cascading) Select List</a> from my old bolg <a href="http://php4bd.wordpress.com" target="_blank">http://php4bd.wordpress.com</a> and here. </p>
<p>I am getting a lots of request and questions from visitors about adding some features and some other problems. Sometimes I faced some problem when using this script myself. So, I have made some changes here. I hope, this change will help you to overcome some problems of previous version of this script. The main features added in this version are:</p>
<ol>
<li>It will keep in child list box only sub items of selected parent value when initializing. </li>
<li>Added a 4th parameter to input a selected value for child list box. </li>
<li>When &quot;isSubselectOptional&quot; is true, add a default value &#8216;none&#8217; for &#8216;&#8211; Select &#8211;&#8217; option of child list box. </li>
<li>Automatically focus the child list box when a value is selected from parent list box. </li>
<li>More effective for multilevel association. </li>
</ol>
<p>Click <a href="http://www.ajaxray.com/Examples/depend.html" target="_blank">here</a> to see a demo of multilevel association using this function.</p>
<p>Here is the modified function: </p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> <span style="color: #0000ff">function</span> makeSublist(parent,child,isSubselectOptional,childVal)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 3:</span> $(<span style="color: #006080">&quot;body&quot;</span>).append(<span style="color: #006080">&quot;&lt;select style=&#8217;display:none&#8217; id=&#8217;&quot;</span>+parent+child+<span style="color: #006080">&quot;&#8217;&gt;&lt;/select&gt;&quot;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 4:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+parent+child).html($(<span style="color: #006080">&quot;#&quot;</span>+child+<span style="color: #006080">&quot; option&quot;</span>));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 5:</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 6:</span> <span style="color: #0000ff">var</span> parentValue = $(<span style="color: #006080">&#8216;#&#8217;</span>+parent).attr(<span style="color: #006080">&#8216;value&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 7:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+child).html($(<span style="color: #006080">&quot;#&quot;</span>+parent+child+<span style="color: #006080">&quot; .sub_&quot;</span>+parentValue).clone());</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 8:</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 9:</span> childVal = (<span style="color: #0000ff">typeof</span> childVal == <span style="color: #006080">&quot;undefined&quot;</span>)? <span style="color: #006080">&quot;&quot;</span> : childVal ;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 10:</span> $(<span style="color: #006080">&quot;#&quot;</span>+child+<span style="color: #006080">&#8216; option[@value=&quot;&#8217;</span>+ childVal +<span style="color: #006080">&#8216;&quot;]&#8217;</span>).attr(<span style="color: #006080">&#8217;selected&#8217;</span>,<span style="color: #006080">&#8217;selected&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 11:</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 12:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+parent).change( </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 13:</span> <span style="color: #0000ff">function</span>()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 14:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 15:</span> <span style="color: #0000ff">var</span> parentValue = $(<span style="color: #006080">&#8216;#&#8217;</span>+parent).attr(<span style="color: #006080">&#8216;value&#8217;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 16:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+child).html($(<span style="color: #006080">&quot;#&quot;</span>+parent+child+<span style="color: #006080">&quot; .sub_&quot;</span>+parentValue).clone());</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 17:</span> <span style="color: #0000ff">if</span>(isSubselectOptional) </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 18:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+child).prepend(<span style="color: #006080">&quot;&lt;option value=&#8217;none&#8217;&gt; &#8212; Select &#8212; &lt;/option&gt;&quot;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 19:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+child).trigger(<span style="color: #006080">&quot;change&quot;</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 20:</span> $(<span style="color: #006080">&#8216;#&#8217;</span>+child).focus();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 21:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 22:</span> );</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 23:</span> }</pre>
</p></div>
</div>
<p>And initialize the association on &#x2018;$(document).ready&#x2019;, as following example:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> $(document).ready(<span style="color: #0000ff">function</span>()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 3:</span> makeSublist(&#x2019;parentID&#x2019;,<span style="color: #006080">&#8216;childID&#x2019;, true, &#8216;</span>selected_val_of_child&#8217;);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 4:</span> });</pre>
</p></div>
</div>
<p>If you want to create multilevel association, start the initialization from child most order. such as:</p>
<div>
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 1:</span> $(document).ready(<span style="color: #0000ff">function</span>()</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 3:</span> makeSublist(<span style="color: #006080">&#8216;child&#8217;</span>,<span style="color: #006080">&#8216;grandson&#8217;</span>, <span style="color: #0000ff">true</span>, <span style="color: #006080">&#8221;</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060"> 4:</span> makeSublist(<span style="color: #006080">&#8216;parent&#8217;</span>,<span style="color: #006080">&#8216;child&#8217;</span>, <span style="color: #0000ff">false</span>, <span style="color: #006080">&#8216;3&#8242;</span>); </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#x27;Courier New&#x27;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060"> 5:</span> });</pre>
</p></div>
</div>
<p>For details instruction and example of using this script, please visit the <a href="http://www.ajaxray.com/blog/2007/07/15/javascript-controlled-dependent-or-cascading-select-list/" target="_blank">previous version</a>. Feel free to ask me if any problem with using this script or any bug you found.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ruby on Rails: Begin with the easiest tutorial</title>
		<link>http://www.ajaxray.com/blog/2007/10/10/ruby-on-rails-begin-with-the-easiest-tutorial/</link>
		<comments>http://www.ajaxray.com/blog/2007/10/10/ruby-on-rails-begin-with-the-easiest-tutorial/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 12:38:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ajaxray.com/blog/2007/10/10/ruby-on-rails-begin-with-the-easiest-tutorial/</guid>
		<description><![CDATA[When I have been hearing a lot about Ruby and thinking to give it a try, I searched for a beginners tutorial over Internet. I found a lot. But luckily, I started with the easiest and solid one. It successfully drive me through an exciting way of learning ruby and lift me from installing to [...]]]></description>
			<content:encoded><![CDATA[<p>When I have been hearing a lot about Ruby and thinking to give it a try, I searched for a beginners tutorial over Internet. I found a lot. But luckily, I started with <strong>the easiest and solid</strong> one. It successfully drive me through an exciting way of learning ruby and lift me from installing to a functional &quot;online cookbook&quot; application. The best part of this tutorial was, it teach everything really &quot;step by step&quot; and you have to turn back to a previous step for never. 2 parts of this great tutorial is here -</p>
<p>part-1 : <a href="http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html">Rolling with Ruby on Rails</a></p>
<p>part-2 : <a href="http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html">Rolling with Ruby on Rails, Part 2</a></p>
<p>Ok. It&#8217;s confirming your successful starting. For the next step, I am listing here some essentials of learning Ruby on Rails.</p>
<ol>
<li><a title="http://tryruby.hobix.com/" href="http://tryruby.hobix.com/">http://tryruby.hobix.com/</a> : This is an interactive interface for learning Ruby. They said,&quot;Got 15 minutes? Give Ruby a shot right now!&quot;. </li>
<li><a href="http://www.onlamp.com/pub/a/onlamp/2005/10/13/what_is_rails.html" target="_blank">What is ruby on Rails</a> - This is another tutorial from <a title="http://www.onlamp.com/" href="http://www.onlamp.com/">http://www.onlamp.com/</a> describing amazing features of Ruby on Rails. </li>
<li><a href="http://rails.homelinux.org/">Four Days on Rails (PDF)</a> : This PDF goes through building a &quot;To-Do List&quot; Application. The steps of building a ruby applications are explained here excellently. </li>
<li><a title="http://wiki.rubyonrails.com/rails" href="http://wiki.rubyonrails.com/rails">http://wiki.rubyonrails.com/rails</a> : Ruby on Rails Wiki : The community-driven Rails documentation! A place where you will get everything about Ruby on Rails. </li>
<li><a title="http://api.rubyonrails.com/" href="http://api.rubyonrails.com/">http://api.rubyonrails.com/</a> : The details documentation of Rails API. </li>
<li><a title="http://rubyforge.org/" href="http://rubyforge.org/">http://rubyforge.org/</a> and <a title="http://raa.ruby-lang.org/index.html" href="http://raa.ruby-lang.org/index.html">http://raa.ruby-lang.org/index.html</a>: These are the world&#8217;s richest&#xA0; collection of open source ruby proj