<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Mypaaji</title>
	
	<link>http://mypaaji.com</link>
	<description>Bolo Tara Rara</description>
	<pubDate>Tue, 01 Sep 2009 06:18:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/mypaaji/FsMI" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Ask Sunny: Tree + Load Url - jQuery</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/bfC2OvSrey0/</link>
		<comments>http://mypaaji.com/index.php/2009/09/01/tree-drop-down-javascript-jquery-load-url/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 06:14:52 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[down]]></category>

		<category><![CDATA[drop]]></category>

		<category><![CDATA[drop down]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[load]]></category>

		<category><![CDATA[tree]]></category>

		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=312</guid>
		<description><![CDATA[Some days back my dear friend nikhil(chubey sahb aka Mungeri lal) asked me &#8220;Paaji how to build a drop down like google code and load url on click&#8221;.
Its very easy we can build this within 5 minutes using jQuery.
so here it goes.. 

If you see any room for improvement, or if you can add something [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Some days back my dear friend nikhil(chubey sahb aka <strong>Mungeri lal</strong>) asked me &#8220;Paaji how to build a drop down like google code and load url on click&#8221;.<br />
Its very easy we can build this within 5 minutes using jQuery.<br />
so here it goes.. <img src='http://mypaaji.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-312"></span><br />
<em>If you see any room for improvement, or if you can add something than go ahead and comment and I will definitely give it a look for possible inclusion.</em></p>
<div class="tutorial_image"><a href="http://mypaaji.com/tut/tree/tree.zip"><img width="221" height="62" class="alignnone size-full wp-image-199" title="source" alt="source" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif"/></a><a href="http://mypaaji.com/tut/tree/"><img width="221" height="62" class="alignnone size-full wp-image-198" title="demo" alt="demo" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif"/></a></div>
<h3>Setup</h3>
<p>Include <a href="http://jquery.com">jQuery</a> in your html file, you can download it from here <a href="http://docs.jquery.com/Downloading_jQuery">Download jQuery</a>.</p>
<pre class="brush: html">
&lt;script src=&quot;jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<h3>Markup</h3>
<p>Time to write some html and css.</p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;Tree&lt;/title&gt;
&lt;script src=&quot;jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
.collapse{display:none}
&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;ul id=&quot;tree&quot;&gt;
	&lt;li&gt;
		&lt;a href=&quot;#&quot;&gt;First&lt;/a&gt;
		&lt;ul class=&quot;collapse&quot;&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;First Child&lt;/a&gt;
			&lt;/li&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;First Second Child&lt;/a&gt;
			&lt;/li&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;First Third Child&lt;/a&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;a href=&quot;#&quot;&gt;Second&lt;/a&gt;
		&lt;ul class=&quot;collapse&quot;&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;Second Child&lt;/a&gt;
			&lt;/li&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;Second Second Child&lt;/a&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;
		&lt;a href=&quot;#&quot;&gt;Third&lt;/a&gt;
		&lt;ul class=&quot;collapse&quot;&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;Third Child&lt;/a&gt;
			&lt;/li&gt;
			&lt;li&gt;
				&lt;a href=&quot;your.html&quot;&gt;Third Second Child&lt;/a&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;

&lt;div id=&quot;showPage&quot;&gt;
&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>JQuery - The Rockstar</h3>
<pre class="brush: js">
$(document).ready(function()
{
	$(&#039;#tree li a&#039;).click(function()
	{
		mainObj	= $(this);

		obj	= mainObj.next();
		obj.toggle(&#039;slow&#039;); // Remove slow If you dont want any animation
		obj.find(&#039;a&#039;).click(function()
		{
			url	= $(this).attr(&#039;href&#039;); // store href value
			$(&#039;#showPage&#039;).load(url);// loading url and showing the content in a div of id showPage
			return false;// its important <img src='http://mypaaji.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
 		})

	});
})
</pre>
<p>I know its not very well explained but what can I do, am very bad in explaining things and some times lazy too.. <img src='http://mypaaji.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><em>If you see any room for improvement, or if you can add something than go ahead and comment and I will definitely give it a look for possible inclusion.</em></p>
<div class="tutorial_image"><a href="http://mypaaji.com/tut/tree/tree.zip"><img width="221" height="62" class="alignnone size-full wp-image-199" title="source" alt="source" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif"/></a><a href="http://mypaaji.com/tut/tree/"><img width="221" height="62" class="alignnone size-full wp-image-198" title="demo" alt="demo" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif"/></a></div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/bfC2OvSrey0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/09/01/tree-drop-down-javascript-jquery-load-url/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/09/01/tree-drop-down-javascript-jquery-load-url/</feedburner:origLink></item>
		<item>
		<title>WWE with Suraj and Pison - Video</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/JOgOWM73R_A/</link>
		<comments>http://mypaaji.com/index.php/2009/08/28/wwe-with-suraj-and-pison-video/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 07:43:09 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[JLT]]></category>

		<category><![CDATA[funny]]></category>

		<category><![CDATA[just like that]]></category>

		<category><![CDATA[lol]]></category>

		<category><![CDATA[pison]]></category>

		<category><![CDATA[sunny]]></category>

		<category><![CDATA[suraj]]></category>

		<category><![CDATA[wwe]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=304</guid>
		<description><![CDATA[


No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-306" title="surajpisonsunny" src="http://mypaaji.com/wp-content/uploads/2009/08/surajpisonsunny.jpg" alt="surajpisonsunny" width="600" height="462" /><span id="more-304"></span><object width="400" height="300" data="http://vimeo.com/moogaloop.swf?clip_id=5156467&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=5156467&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /></object></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/JOgOWM73R_A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/08/28/wwe-with-suraj-and-pison-video/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/08/28/wwe-with-suraj-and-pison-video/</feedburner:origLink></item>
		<item>
		<title>Object Oriented Programming - PHP</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/URW4oHQsLwA/</link>
		<comments>http://mypaaji.com/index.php/2009/08/07/object-oriented-programming-php/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 13:40:11 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[class]]></category>

		<category><![CDATA[object]]></category>

		<category><![CDATA[object oriented programming]]></category>

		<category><![CDATA[orinted]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=286</guid>
		<description><![CDATA[Object - Oriented (OO) software development can be a confusing topic for developers who create primarily procedural code. But it doesn&#8217;t need to be. In this post, you&#8217;ll explore some of the basic theory behind OO and cover its (sometimes daunting) multisyllabic terminology.

What Is Object-Oriented Programming?
Object-Oriented Programming (OOP) requires a different way of thinking about [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Object - Oriented (OO) software development can be a confusing topic for developers who create primarily procedural code. But it doesn&#8217;t need to be. In this post, you&#8217;ll explore some of the basic theory behind OO and cover its (sometimes daunting) multisyllabic terminology.<br />
<span id="more-286"></span><br />
<h3>What Is Object-Oriented Programming?</h3>
<p>Object-Oriented Programming (OOP) requires a different way of thinking about how you construct your applications. Objects enable you to more closely model in code the real-world tasks, processes, and ideas that your application is designed to handle. Instead of thinking about an application as a thread of control that passes chunks of data from one function to the next, an OOP approach allows you to model the application as a set of collaborating objects that independently handle certain activities.</p>
<h3>Understanding OOP Concepts</h3>
<p>&rarr; <em>classes</em>: the &#8220;blueprints&#8221; for an object and the actual code that defines the properties and methods.</p>
<p>&rarr; <em>objects</em>: running instances of a class, that contains all the internal data and state information needed for your application to function.</p>
<p>&rarr; <em>inheritance</em>: the ability to define a class of one kind as being a subtype of a different kind of class (much the same way as a square is a kind of rectangle).</p>
<p>&rarr; <em>polymorphism</em>: allows a class to be defined as being a member of more than one category of classes (just as a car is &#8220;a thing with an engine&#8221; and &#8220;a thing with wheel&#8221;).</p>
<p>&rarr; <em>interfaces</em>: defines a contract specifying that an object is capable of implementing a method without actually defining how it is to be done.</p>
<p>&rarr; <em>encapsulation</em>: the ability of an object to protect access to its internal data.</p>
<h3>Creating a Class</h3>
<p>Start with a simple example. Save the following code in a file called class.Demo.php</p>
<pre class="brush: php">
&lt;?php
class Demo
{

}
?&gt;
</pre>
<p><em>Its important to have a clearly defined convention for organizing your source code file. A good rule to follow is to put each class into its own file and to name that file <strong>class.[ClassName].php</strong></em></p>
<p>you can instantiate an object of type Demo like this</p>
<pre class="brush: php">
&lt;?php

require_once(&#039;class.Demo.php&#039;);

$objDemo = new Demo();

?&gt;
</pre>
<p>to instantiate an object, first make sure that PHP knows where to find the class declaration by including the file containing your class (class.Demo.php in this example).</p>
<h3>Adding a Method</h3>
<p>The Demo class isn&#8217;t particularly useful if it isn&#8217;t able to do anything, so let&#8217;s look at how you can create a method. Remember, a method of a class is basically just a function. By coding a function inside the braces of your class, you&#8217;re adding a method to that class. Here&#8217;s an example:</p>
<pre class="brush: php">
&lt;?php

class Demo
{
    function sayHello($name)
    {
         print &quot;Hello $name!&quot;;
    }
}

?&gt;
</pre>
<p>An object derived from your class is now capable of printing a greeting to anyone who invokes the <strong>sayHello</strong> method. To invoke the method on your <strong>$objDemo</strong> object, you need to use the operator &#8220;->&#8221; to access the newly created function:</p>
<pre class="brush: php">
&lt;?php

require_once(&#039;class.Demo.php&#039;);

$objDemo = new Demo();

$objDemo -&gt; sayHello(&#039;Bajrangi Baba&#039;);

?&gt;
</pre>
<p>The object is now capable of printing a friendly greeting. The &#8220;->&#8221; operator is used to access all methods the properties of your objects.</p>
<h3>Adding a Property</h3>
<p>Adding a property to your class is as simple as adding a method. You simply declare a variable inside the class to hold the value of the property.<br />
Open the class.Demo.php file and do the respective changes:</p>
<pre class="brush: php">
&lt;?php

class Demo
{
    public $name;
    function sayHello()
    {
         print &quot;Hello $this-&gt;name!&quot;;
    }
}

?&gt;
</pre>
<p>The new variable, called <strong>$name</strong>, is all you have to do to create a property of the Demo class called name.<br />
To access this property, you use the same &#8220;->&#8221; operator as that of the previous example, along with the name of the property.<br />
Create a new file called testdemo.php and add the following:</p>
<pre class="brush: php">
&lt;?php

require_once(&#039;class.Demo.php&#039;);

$objDemo = new Demo();
$objDemo -&gt; name = &#039;Pison&#039;;

$objAnotherDemo = new Demo();
$objAnotherDemo -&gt; name = &#039;Bajrangi Baba&#039;;

$objDemo -&gt; sayHello();
$objAnotherDemo -&gt; sayHello();

?&gt;
</pre>
<p>Save the file and open it in your Web browser. The strings <strong>&#8220;Hello Pison&#8221;</strong> and <strong>&#8220;Hello Bajrangi Baba&#8221;</strong> print to the screen.<br />
The Keyword <strong>public</strong> is used to let the class know that you want to have access to the following variable from outside the class.</p>
<h3>Protecting Access to Member Variables</h3>
<p>As the previous example shows, you can set the value of the name property to just about anything you want - including an object, an array of integers, a file handle or any other nonsensical value.<br />
To work around this problem, always implement your properties in the form of function called <strong>get[property name]</strong> and <strong>set[property name]</strong>. Such functions are known as accessor methods, and are demonstrated in the following example.</p>
<p>Make the changes as the following to class.Demo.php</p>
<pre class="brush: php">
&lt;?php

class Demo
{
    private $_name;

    public function sayHello()
    {
        print &quot;Hello {$this -&gt; getName()}!&quot;;
    }

    public function getName()
   {
       return $this -&gt; $_name;
   }

   public function setName($name)
   {
       if(!is_string($name) || strlen($name)==0)
       {
           throw new Exception(&quot;Invalid Name Value&quot;);
       }
       $this -&gt; _name = $name;
   }
}

?&gt;
</pre>
<p>Edit testdemo.php as shown here</p>
<pre class="brush: php">
&lt;?php

require_once(&#039;class.Demo.php&#039;);

$objDemo = new Demo();
$objDemo -&gt; setName(&#039;Pison&#039;);
$objDemo -&gt; sayHello();

$objDemo -&gt; setName(69);  //would trigger an error ; )

?&gt;
</pre>
<p>As you can see, the member access level of name has changed from public to private and has been prefixed with underscore. The underscore is a recommended naming convention to indicate private member variables and functions; however its merely a convention - PHP does not require it.</p>
<p><em>Always use accessor methods for your properties. Change to business logic and data validation requirement in the future will be much easier to implement.</em></p>
<h3>Initializing Objects</h3>
<p>For many classes you will create, you will need to do some special set-up when an object of that class is firs instantiated. You might need to fetch some information from a database, or initialize some property values, for example. By creating a special method called a <em>constructor</em>, Implemented in PHP using a function called <strong>__construct()</strong>, you can perform any activities required to instantiate the object. PHP will automatically call this special function when instantiating the object.<br />
For example you could rewrite the demo class in the following way:</p>
<pre class="brush: php">
&lt;?php

class Demo
{
    private $_name;
    public function __construct($name)
    {
        $this -&gt; _name = $name;
    }
    public function sayHello()
    {
        print &quot;Hello $this -&gt; _name&quot;;
    }
}

?&gt;
</pre>
<p>You can instantiate an object like as follows:</p>
<pre class="brush: php">
&lt;?php

require_once(&#039;class.Demo.php&#039;);

$objDemo = new Demo(&#039;Pison&#039;);
$objDemo -&gt; sayHello();

?&gt;
</pre>
<p>That&#8217;s It guys:)</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/URW4oHQsLwA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/08/07/object-oriented-programming-php/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/08/07/object-oriented-programming-php/</feedburner:origLink></item>
		<item>
		<title>PHP Quick Reference</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/dWWp3npXu08/</link>
		<comments>http://mypaaji.com/index.php/2009/08/07/php-quick-reference/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 07:06:05 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Wrap Up]]></category>

		<category><![CDATA[arrays]]></category>

		<category><![CDATA[basics]]></category>

		<category><![CDATA[comprehensive]]></category>

		<category><![CDATA[functions]]></category>

		<category><![CDATA[important]]></category>

		<category><![CDATA[net]]></category>

		<category><![CDATA[operators]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[quick]]></category>

		<category><![CDATA[reference]]></category>

		<category><![CDATA[strings]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=278</guid>
		<description><![CDATA[This PHP Quick Reference gives a comprehensive overview of the basics of PHP, covering important subjects such as control structures, strings, arrays and sessions, and more.
For downloads and more information, please visit the official PHP site: http://www.php.net

Marking PHP Code
Sections of PHP code start with < ?php and end with ? > . An example of [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://www.php.net">PHP</a> Quick Reference gives a comprehensive overview of the basics of <a href="http://www.php.net">PHP</a>, covering important subjects such as control structures, strings, arrays and sessions, and more.</p>
<p>For downloads and more information, please visit the official <a href="http://www.php.net">PHP</a> site: <a href="http://www.php.net">http://www.php.net</a><br />
<span id="more-278"></span></p>
<h3>Marking PHP Code</h3>
<p>Sections of PHP code start with < ?php and end with ? > . An example of this syntax is:</p>
<pre class="brush: php">
&lt;?php

// enter lines of code, make sure they end with a semicolon;

?&gt;</pre>
<p>You can also use <strong>< script language= " PHP " > </script></strong> to delimit your code, but the above<br />
syntax is more convenient.</p>
<h3>Displaying to Browser</h3>
<p>The echo and print constructs are used to display text in a browser:</p>
<pre class="brush: php">
echo &#039;Enter text here&#039;; // echo text

echo $variable; // echo values

echo &#039; &lt;br/&gt; &#039;; // echo HTML text</pre>
<h3>Comments</h3>
<p>It &#8216; s always a good idea to comment your code. PHP gives you two ways to do so:</p>
<pre class="brush: php">
// This is a single line comment that runs to the end of the line.

/* This is a multiple line comment and
can
span
multiple
lines. */</pre>
<h3>Variables</h3>
<p>Variables are named references to locations in memory. Variable names start with $ . Legal variable<br />
names consist of numbers, letters, and the underscore character but cannot start with a number.</p>
<pre class="brush: php">$MyVariable // valid
$1stVariable // invalid (cannot start with a number)

$variable_1 // valid

//To assign a value to a variable, use the following syntax:

$variable_1 = 123;

$variable_2 = &#039;value&#039;;
</pre>
<h3>Passing Variables</h3>
<p>You can pass variables among pages in your Web site in three ways: through a URL, through sessions,<br />
and through a form.</p>
<p><em><strong>Through a URL</strong></em><br />
To pass a variable through a URL, use the following format:<br />
<strong>http://www.example.com?variable1=value &#038; variable2=value</strong></p>
<p><em><strong>Through Sessions</strong></em><br />
To pass a variable through a session, use the following PHP code:</p>
<pre class="brush: php">
session_start(); // starts session handling

$_SESSION[&#039;var_name1&#039;] = value; // sets values for the entire session

$_SESSION[&#039;var_name2&#039;] = value;
</pre>
<p>session_start() must be used in every script that sets or accesses session variables. It must be called<br />
before any output is sent to the browser.</p>
<p><em><strong>Through a Form</strong></em><br />
A form element&#8217;s action attribute must reference the PHP script that will parse the variables:<br />
< form action= "process.php" ><br />
The variables can be referenced from the $_POST and $_GET arrays, depending on the form element &#8216; s<br />
method:</p>
<pre class="brush: php">
$value = $_POST[&#039;varname&#039;]; // this is how you will access the values from a form with method=&quot;post&quot;

$value = $_GET[&#039;varname&#039;]; // this is how you will access the values from a form with method=&quot;get&quot;
</pre>
<h3>Strings</h3>
<p>A string is a set of characters delimited by quotation marks. Either single quotation marks or double<br />
quotation marks can be used, but PHP treats these differently. Variables that appear within<br />
double - quoted strings will be interpolated. Variables within single - quoted strings will not be.</p>
<pre class="brush: php">
$var = 42;
echo &quot;The answer to life, the universe and everything is: $var.&quot; ;
// The answer to life, the universe and everything is 42.

echo &#039;The answer to life, the universe and everything is: $var.&#039;;
// The answer to life, the universe and everything is $var.

// \ is used to escape characters within strings:
echo &#039;&lt; a href= &quot; link.php &quot; &gt; Don\&#039;t Click on Me! &lt; /a &gt; &#039;;

//Two strings can be joined together with the . operator:
$piece_1 = &#039;Hello&#039;;
$piece_2 = &#039;World&#039;;

echo $piece_1 . &#039;&#039; . $piece_2; // Hello World
</pre>
<h3>if Statements</h3>
<p>if statements are used to mark sections of code that should be executed only if a given condition is true:</p>
<pre class="brush: php">
if (condition)
	// execute this one statement if true;

if (true condition) {
	// execute statement 1;
	// execute statement 2;
	// execute statement 3;
}
</pre>
<h3>else Statements</h3>
<p>if / else statements branch code depending on whether a condition is true or false:</p>
<pre class="brush: php">
if (condition)
	//execute this statement if true;
else
	//execute this statement false;

if (condition) {
	// execute statement 1;
	// execute statement 2;
	// execute statement 3;
} else {
	// execute statement 4;
	// execute statement 5;
	// execute statement 6;
}
</pre>
<p>The ternary operator ( ?: ) is a shorthand notation for simple if / else statements:</p>
<pre class="brush: php">
$var = (true) ? &#039;value 1&#039; : &#039;value 2&#039;;
</pre>
<p>is the same as:</p>
<pre class="brush: php">
if (true) {
	$var = &#039;value 1&#039;;
} else {
	$var = &#039;value 2&#039;;
}</pre>
<h3>Nested if Statements</h3>
<pre class="brush: php">
if (condition A) {
	if (condition B) {
		// execute this statement if A and B are true;
	}
	else if (condition C) {
		// execute this statement if A and C are true;
	} else {
		// execute this statement if A is true and B and C are false;
	}
}</pre>
<h3>Including a File</h3>
<p>To include PHP code from another file, use one of the following statements:</p>
<pre class="brush: php">
include &#039;header.php&#039;; // include file header.php (PHP will continue processing even if file is not found)

include_once &#039;header.php&#039;; // ensure file header.php is only included once even if attempt to include same file again later inprocessing)

require &#039;header.php&#039;; // include file header.php (PHP will terminate with error if file is not found)

require_once &#039;header.php&#039;; // ensure file header.php is only included once even if attempt to include same file again later
</pre>
<h3>Arrays</h3>
<p>An array is a collection of data represented by the same variable name but accessible by indexes. Indexes<br />
can be either numeric or strings.</p>
<pre class="brush: php">
$name = array(&#039;first_name&#039; = &gt; &#039;Sunny&#039;, &#039;last_name&#039; = &gt; &#039;luthra&#039;);

echo $name[&#039;first_name&#039;];
</pre>
<p>If no keys are required, you can set the values for an array like this and let PHP automatically assign<br />
numeric keys starting at 0:</p>
<pre class="brush: php">
$flavors = array(&#039;blue raspberry&#039;, &#039;root beer&#039;, &#039;pineapple&#039;);
echo $flavor[0];
</pre>
<p>New elements can be added to an array after it is defined:</p>
<pre class="brush: php">
$states = array();
$states[&#039;AL&#039;] = &#039;Alabama&#039;;
$states[&#039;AK&#039;] = &#039;Alaska&#039;;
$states[&#039;AZ&#039;] = &#039;Arizona&#039;;
</pre>
<h3>Loops</h3>
<p>PHP has numerous looping structures to repeat the execution of a block of code: while, do/while, for,<br />
and foreach.</p>
<p><em><strong>while</strong></em><br />
You can execute a section of code repeatedly while a given condition is true, with a while statement:</p>
<pre class="brush: php">
$n = 0;
while ($n &lt; 10) {
	// these lines will execute while the value of $n is
	// less than 10
	echo $n . &#039; &lt; br / &gt; &#039;;
	$n = $n + 1;
}
echo $n;
</pre>
<p><em><strong>do/while</strong></em><br />
You can execute a section of code repeatedly while a given condition is true, with a do / while statement.<br />
Unlike a while statement, the loop is guaranteed to run at least once because the condition is not tested<br />
until the end of the block:</p>
<pre class="brush: php">
$n = 0;
do {
	// these lines will execute while the value of $n is
	// less than 10
	echo $n . &#039; &lt; br / &gt; &#039;;
	$n = $n + 1;
} while ($n &lt; 10);
</pre>
<p><em><strong>for</strong></em><br />
You can execute a block of code a specified number of times with the for statement:</p>
<pre class="brush: php">
for ($n = 0; $n &lt; 10; $n = $n + 1) {
	// this will execute while the value of $n is
	// less than 10
	echo $n . &#039; &lt; br/ &gt; &#039;;
}
</pre>
<p><em><strong>foreach</strong></em><br />
You can apply the same block of code to each value in a given array with the foreach statement:</p>
<pre class="brush: php">
foreach ($arrayvalue as $currentvalue) {
	// this will execute as long as there is a value in $arrayvalue
	echo $currentvalue . &#039; &lt; br/ &gt; &#039;;
}
</pre>
<p>In addition to each value in the array, you can also identify the index or key:</p>
<pre class="brush: php">
foreach ($arrayvalue as $currentkey = &gt; $currentvalue) {
	// this will execute as long as there is a value in $arrayvalue
	echo $currentkey . &#039;:&#039; . currentvalue . &#039; &lt; br/ &gt; &#039;;
}
</pre>
<h3>Functions</h3>
<p>You can create and call functions using the following syntax:</p>
<pre class="brush: php">
function funcname() // defines the function
{
	// line of php code;
	// line of php code;
}
funcname(); // calls the function to execute
</pre>
<p>Values can be passed in and returned from functions:</p>
<pre class="brush: php">
function add($value1, $value2) // add two numbers together
{
	$value3 = $value1 + $value2;
	return $value3;
}
$val = funcname(1, 1); // $val = 2
</pre>
<h3>Classes</h3>
<p>You can define new objects and use its methods using the following syntax:</p>
<pre class="brush: php">
class ClassName() // class definition
{
	public $var1; // property with public access
	private $var2; // property with private access

	// constructor method
	public function __construct() {
		// code to initialize object goes here
	}

	// public method
	public function setFoo($value) {
		// properties and methods are accessed inside the class
		// using $this-&gt;
		$this-&gt; var2 = $value;
	}

	// private method
	private function bar() {
		// more code goes here
	}

	// destructor method
	public function __destruct() {
		// clean up code goes here
	}
}
$c = new ClassName(); // create a new instance of the object
$c-&gt; var1 = 42; // properties and methods are accessed using - &gt;
$c-&gt; setFoo(&#039;Hello World&#039;);
</pre>
<h3>Namespaces</h3>
<p>Namespaces are one of the more recent additions to PHP &#8216; s syntax (added in version 5.3) and help<br />
prevent name clashing. Namespaces can contain class, constant, and function definitions. Namespaces<br />
are declared with the namespace keyword at the beginning of a file:</p>
<pre class="brush: php">
namespace MyProject\Foo\Bar;
function fizz() {
	// ...
}
</pre>
<p>When using functions and classes that are defined within a namespace, they can be referenced by their<br />
full name:</p>
<pre class="brush: php">
$var = MyProject::Foo::Bar::fizz();
</pre>
<p>Namespaces can be imported with the use keyword:</p>
<pre class="brush: php">
use MyProject\Foo\Bar;
$var = fizz();
</pre>
<p>Namespaces can be aliased with use / as :</p>
<pre class="brush: php">
use MyProject\Foo\Bar as my;
$var = my\fizz();
</pre>
<h3>Using MySQL</h3>
<p>This is the basic sequence for connecting to a MySQL database, executing a SELECT query and<br />
displaying the results:</p>
<pre class="brush: php">
// connect to MySQL
$db = mysql_connect(&#039;localhost&#039;, &#039;username&#039;, &#039;password&#039;) or
die (&#039;Unable to connect. Check your connection parameters.&#039;);

// select the correct database
mysql_select_db(&#039;database&#039;, $db) or die(mysql_error($db));

// query the database
$query = &#039;SELECT column1, column2 FROM table ORDER BY column1 ASC&#039;;
$result = mysql_query($query, $db) or die (mysql_error($db));

// check if any rows were returned
if (mysql_num_rows($result) &gt; 0) {
	// cycle through the returned records
	while ($row = mysql_fetch_assoc($result)) {
		echo &#039;column1: &#039; . $row[&#039;column1&#039;] . &#039; &lt; br/ &gt; &#039;;
		echo &#039;column2: &#039; . $row[&#039;column2&#039;] . &#039; &lt; br/ &gt; &#039;;
	}
}
// free the result resource
mysql_free_result($result);

// disconnect from MySQL
mysql_close($db);
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/dWWp3npXu08" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/08/07/php-quick-reference/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/08/07/php-quick-reference/</feedburner:origLink></item>
		<item>
		<title>jQuery Plugin - Image Zoom In and Out</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/seB29MYILzg/</link>
		<comments>http://mypaaji.com/index.php/2009/07/31/jquery-plugin-image-zoom-in-and-out/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 04:49:57 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[image]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[mouse wheel]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=273</guid>
		<description><![CDATA[This plugin adds a functionality of zooming image in and out from mouse wheel. Its built on the mouse wheel plugin by Brandon Aaron.
If you see any room for improvement, or if you can add something than go ahead and comment and I will definitely give it a look for possible inclusion.

Setup
First include jQuery library, [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This plugin adds a functionality of zooming image in and out from mouse wheel. Its built on the <a href="http://brandonaaron.net/code/mousewheel/demos">mouse wheel plugin</a> by <a href="http://brandonaaron.net/">Brandon Aaron</a>.<br />
If you see any room for improvement, or if you can add something than go ahead and comment and I will definitely give it a look for possible inclusion.<span id="more-273"></span></p>
<div class="tutorial_image"><a href="http://mypaaji.com/wp-content/uploads/2009/07/imagezoom.zip"><img width="221" height="62" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif" alt="source" title="source" class="alignnone size-full wp-image-199"/></a><a href="http://mypaaji.com/tut/imageZoom/"><img width="221" height="62" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif" alt="demo" title="demo" class="alignnone size-full wp-image-198"/></a></div>
<h3>Setup</h3>
<p>First include jQuery library, <a href="http://brandonaaron.net/code/mousewheel/demos">mouse wheel plugin</a> by <a href="http://brandonaaron.net/">Brandon Aaron</a>, and imageZoom. You can include <a href="http://gsgd.co.uk/sandbox/jquery/easing/">Easing library</a> if in case you need easing on zoom in and out.</p>
<pre class="brush: js">
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.imageZoom.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.mousewheel.js&quot;&gt;&lt;/script&gt;

&lt;!--Optional Easing Script--&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.easing.1.3.js&quot;&gt;&lt;/script&gt;
</pre>
<h3>Initialize imageZoom</h3>
<pre class="brush: js">
$(&#039;#selectorId&#039;).imageZoom(
{
	minWidth:&#039;100&#039;, //minimum width
	maxWidth:&#039;300&#039;,// maximum width
	increaseBy:&#039;120&#039;,//Zoom image by pixels
	duration:2000,//animation duration
	cursor:&#039;pointer&#039;,//cursor type
	easing:&#039;easeOutBack&#039; //easing type
});
</pre>
<div class="tutorial_image"><a href="http://mypaaji.com/wp-content/uploads/2009/07/imagezoom.zip"><img width="221" height="62" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif" alt="source" title="source" class="alignnone size-full wp-image-199"/></a><a href="http://mypaaji.com/tut/imageZoom/"><img width="221" height="62" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif" alt="demo" title="demo" class="alignnone size-full wp-image-198"/></a></div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/seB29MYILzg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/07/31/jquery-plugin-image-zoom-in-and-out/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/07/31/jquery-plugin-image-zoom-in-and-out/</feedburner:origLink></item>
		<item>
		<title>PHP Functions For Daily Use</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/b6LBGFVG3To/</link>
		<comments>http://mypaaji.com/index.php/2009/07/24/useful-php-functions-for-daily-use/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 04:46:21 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Wrap Up]]></category>

		<category><![CDATA[Daily]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Small]]></category>

		<category><![CDATA[Useful]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=269</guid>
		<description><![CDATA[Following is a list of some of the most useful PHP functions that a PHP developer will need at any point in his career. If you see any room for improvement, or if you can add something than go ahead and comment and I will definately give it a look for possible inclusion.

Strip Slashes
Removes slashes [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Following is a list of some of the most useful PHP functions that a PHP developer will need at any point in his career. If you see any room for improvement, or if you can add something than go ahead and comment and I will definately give it a look for possible inclusion.</p>
<p><span id="more-269"></span></p>
<h3>Strip Slashes</h3>
<p>Removes slashes contained in a string or in an array</p>
<pre class="brush: php">
/**
 * Strip Slashes
 *
 * Removes slashes contained in a string or in an array
 *
 * @param	mixed	string or array
 * @return	mixed	string or array
 */	

function strip_slashes($str)
{
	if (is_array($str))
	{
		foreach ($str as $key =&gt; $val)
		{
			$str[$key] = strip_slashes($val);
		}
	}
	else
	{
		$str = stripslashes($str);
	}

	return $str;
}
</pre>
<h3>Strip Quotes</h3>
<p>Removes single and double quotes from a string</p>
<pre class="brush: php">
/**
 * Strip Quotes
 *
 * Removes single and double quotes from a string
 *
 * @param	string
 * @return	string
 */	

function strip_quotes($str)
{
	return str_replace(array(&#039;&quot;&#039;, &quot;&#039;&quot;), &#039;&#039;, $str);
}
</pre>
<h3>Quotes to Entities</h3>
<p>Converts single and double quotes to entities</p>
<pre class="brush: php">
/**
 * Quotes to Entities
 *
 * Converts single and double quotes to entities
 *
 * @param	string
 * @return	string
 */	

function quotes_to_entities($str)
{
	return str_replace(array(&quot;\&#039;&quot;,&quot;\&quot;&quot;,&quot;&#039;&quot;,&#039;&quot;&#039;), array(&quot;&amp;#39;&quot;,&quot;&amp;quot;&quot;,&quot;&amp;#39;&quot;,&quot;&amp;quot;&quot;), $str);
}
</pre>
<h3>Reduce Double Slashes</h3>
<p>Converts double slashes in a string to a single slash, except those found in http:// .</p>
<pre class="brush: php">
/**
 * Reduce Double Slashes
 *
 * Converts double slashes in a string to a single slash,
 * except those found in http://
 *
 * http://www.mypaaji.com//index.php
 *
 * becomes:
 *
 * http://www.mypaaji.com/index.php
 *
 * @param	string
 * @return	string
 */	

function reduce_double_slashes($str)
{
	return preg_replace(&quot;#([^:])//+#&quot;, &quot;\\1/&quot;, $str);
}
</pre>
<h3>Reduce Multiples</h3>
<p>Reduces multiple instances of a particular character. Example: <strong>Sunny, Yuvi,, Ashwini, Sneha </strong> becomes: <strong>Sunny, Yuvi, Ashwini, Sneha</strong></p>
<pre class="brush: php">
/**
 * Reduce Multiples
 *
 * Reduces multiple instances of a particular character.  Example:
 *
 * Sunny, Yuvi,, Ashwini, Sneha
 *
 * becomes:
 *
 * Sunny, Yuvi, Ashwini, Sneha
 *
 * @param	string
 * @param	string	the character you wish to reduce
 * @param	bool	TRUE/FALSE - whether to trim the character from the beginning/end
 * @return	string
 */	

function reduce_multiples($str, $character = &#039;,&#039;, $trim = FALSE)
{
	$str = preg_replace(&#039;#&#039;.preg_quote($character, &#039;#&#039;).&#039;{2,}#&#039;, $character, $str);

	if ($trim === TRUE)
	{
		$str = trim($str, $character);
	}

	return $str;
}
</pre>
<h3>Create a Random String</h3>
<p>Useful for generating passwords or hashes.</p>
<pre class="brush: php">
/**
 * Create a Random String
 *
 * Useful for generating passwords or hashes.
 *
 * @param	string 	type of random string.  Options: alunum, numeric, nozero, unique
 * @param	integer	number of characters
 * @return	string
 */
function random_string($type = &#039;alnum&#039;, $len = <img src='http://mypaaji.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' />
{
	switch($type)
	{
		case &#039;alnum&#039;	:
		case &#039;numeric&#039;	:
		case &#039;nozero&#039;	:

				switch ($type)
				{
					case &#039;alnum&#039;	:	$pool = &#039;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&#039;;
						break;
					case &#039;numeric&#039;	:	$pool = &#039;0123456789&#039;;
						break;
					case &#039;nozero&#039;	:	$pool = &#039;123456789&#039;;
						break;
				}

				$str = &#039;&#039;;
				for ($i=0; $i &lt; $len; $i++)
				{
					$str .= substr($pool, mt_rand(0, strlen($pool) -1), 1);
				}
				return $str;
		  break;
		case &#039;unique&#039; : return md5(uniqid(mt_rand()));
		  break;
	}
}
</pre>
<h3>Word Censoring Function</h3>
<p>Supply a string and an array of disallowed words and any matched words will be converted to <strong>####</strong> or to the replacement word you&#8217;ve submitted.</p>
<pre class="brush: php">
/**
 * Word Censoring Function
 *
 * Supply a string and an array of disallowed words and any
 * matched words will be converted to #### or to the replacement
 * word you&#039;ve submitted.
 *
 * @param	string	the text string
 * @param	string	the array of censoered words
 * @param	string	the optional replacement value
 * @return	string
 */	

function word_censor($str, $censored, $replacement = &#039;&#039;)
{
	if ( ! is_array($censored))
	{
		return $str;
	}

	$str = &#039; &#039;.$str.&#039; &#039;;
	foreach ($censored as $badword)
	{
		if ($replacement != &#039;&#039;)
		{
			$str = preg_replace(&quot;/\b(&quot;.str_replace(&#039;\*&#039;, &#039;\w*?&#039;, preg_quote($badword)).&quot;)\b/i&quot;, $replacement, $str);
		}
		else
		{
			$str = preg_replace(&quot;/\b(&quot;.str_replace(&#039;\*&#039;, &#039;\w*?&#039;, preg_quote($badword)).&quot;)\b/ie&quot;, &quot;str_repeat(&#039;#&#039;, strlen(&#039;\\1&#039;))&quot;, $str);
		}
	}

	return trim($str);
}
</pre>
<h3>Word Limiter</h3>
<p>Limits a string to X number of words.</p>
<pre class="brush: php">
/**
 * Word Limiter
 *
 * Limits a string to X number of words.
 *
 * @param	string
 * @param	integer
 * @param	string	the end character. Usually an ellipsis
 * @return	string
 */
function word_limiter($str, $limit = 100, $end_char = &#039;&amp;#8230;&#039;)
{
	if (trim($str) == &#039;&#039;)
	{
		return $str;
	}

	preg_match(&#039;/^\s*+(?:\S++\s*+){1,&#039;.(int) $limit.&#039;}/&#039;, $str, $matches);

	if (strlen($str) == strlen($matches[0]))
	{
		$end_char = &#039;&#039;;
	}

	return rtrim($matches[0]).$end_char;
}
</pre>
<h3>Character Limiter</h3>
<p>Limits the string based on the character count. Preserves complete words so the character count may not be exactly as specified.</p>
<pre class="brush: php">
/**
 * Character Limiter
 *
 * Limits the string based on the character count.  Preserves complete words
 * so the character count may not be exactly as specified.
 *
 * @param	string
 * @param	integer
 * @param	string	the end character. Usually an ellipsis
 * @return	string
 */
function character_limiter($str, $n = 500, $end_char = &#039;&amp;#8230;&#039;)
{
	if (strlen($str) &lt; $n)
	{
		return $str;
	}

	$str = preg_replace(&quot;/\s+/&quot;, &#039; &#039;, str_replace(array(&quot;\r\n&quot;, &quot;\r&quot;, &quot;\n&quot;), &#039; &#039;, $str));

	if (strlen($str) &lt;= $n)
	{
		return $str;
	}

	$out = &quot;&quot;;
	foreach (explode(&#039; &#039;, trim($str)) as $val)
	{
		$out .= $val.&#039; &#039;;
		if (strlen($out) &gt;= $n)
		{
			return trim($out).$end_char;
		}
	}
}
</pre>
<p>That&#8217;s it guys I will keep updating this post with more handy functions, Please contribute if you have any. <img src='http://mypaaji.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/b6LBGFVG3To" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/07/24/useful-php-functions-for-daily-use/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/07/24/useful-php-functions-for-daily-use/</feedburner:origLink></item>
		<item>
		<title>Creating A Facebook Application</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/cEFGN3isPm8/</link>
		<comments>http://mypaaji.com/index.php/2009/07/19/creating-a-facebook-application/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 20:40:19 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[facebook]]></category>

		<category><![CDATA[full]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[quiz]]></category>

		<category><![CDATA[scratch]]></category>

		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=247</guid>
		<description><![CDATA[Well today we are going to create a Quiz application for FB (ya ya already there are lots of quiz app floating on FB   so why not one more)
This Tutorial is going to be very brief and point to point because I am very bad in explaining things  ..
If you have any [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Well today we are going to create a Quiz application for FB <em>(ya ya already there are lots of quiz app floating on FB <img src='http://mypaaji.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  so why not one more)</em></p>
<p>This Tutorial is going to be very brief and point to point because I am very bad in explaining things <img src='http://mypaaji.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ..<span id="more-247"></span></p>
<p><strong>If you have any comment or ways to improve it, just leave me a comment!</strong></p>
<div class="tutorial_image"><a href="http://mypaaji.com/tut/facebookQuiz.zip"><img height="62" width="221" class="alignnone size-full wp-image-199" title="source" alt="source" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif"/></a><a href="http://apps.facebook.com/dialoguedrum/"><img height="62" width="221" class="alignnone size-full wp-image-198" title="demo" alt="demo" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif"/></a></div>
<h3>What you need for that?</h3>
<p>1) <strong>Facebook Account</strong></p>
<p>2) <strong>Hosting </strong>(PHP and MySql Support  needed for this demo)</p>
<h3>Lets Start - Step 1 with Facebook</h3>
<p>First you need to log in to the Facebook Developer application: <a class="app_link" href="http://www.facebook.com/developers/">Go to the Facebook Developer App</a>. After following the link, click “Allow” to let the Developer application access your profile.. Then click on the <strong>Set Up New Application</strong> (Highlighted in image given below for you, yes you)</p>
<p><img class="alignnone size-full wp-image-253" title="developer-page" src="http://mypaaji.com/wp-content/uploads/2009/07/developer-page.jpg" alt="developer-page" width="600" height="282" /></p>
<p>After clicking &#8220;setup new application&#8221; you will get a page asking for Application name and agree - disagree radio buttons for their terms. Give your application a nice name and agree to their terms.</p>
<div id="attachment_254" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-254" title="Weird Application name! yes i know." src="http://mypaaji.com/wp-content/uploads/2009/07/application-name.jpg" alt="Weird Application name! yes i know." width="600" height="227" /><p class="wp-caption-text">Weird Application name! yes i know.</p></div>
<p>After submitting you will see a page for editing basic info of the application. everything is self explanatory <img src='http://mypaaji.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> I told you i am very bad in explaining (need a lady teacher.. cute one <img src='http://mypaaji.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> )</p>
<p><em><span style="text-decoration: underline;"><strong>Your API key:</strong></span> this key identifies your application to Facebook. You                   pass it with all your API calls.</em><br />
<em><span style="text-decoration: underline;"><strong></strong></span></em></p>
<p><em><span style="text-decoration: underline;"><strong>Your application secret:</strong></span> Facebook uses this key to authenticate the                   requests you make. As you can tell by its name, you should never share                   this key with anyone.</em></p>
<p><em><img class="alignnone size-full wp-image-259" title="basic-settings" src="http://mypaaji.com/wp-content/uploads/2009/07/basic-settings.jpg" alt="basic-settings" width="600" height="311" /></em></p>
<p>Click on the &#8220;Canvas&#8221; link. Your canvas page is the application area within Facebook; the name is added to the URL and will look like this: <code>http://apps.facebook.com/[YOUR APP NAME]</code>. The callback URL points to the server hosting the app files.  Please look at the image given below (em.. I am getting polite now, wasn&#8217;t i before)</p>
<p><em><span style="text-decoration: underline;"><strong>Render Method:</strong></span><strong> </strong></em>Choose whether you will render your canvas page in an iframe or with FBML. For this APP we will be using FBML</p>
<p><strong>Submit After filling all the details.</strong></p>
<p><img class="alignnone size-full wp-image-260" title="canvas-page" src="http://mypaaji.com/wp-content/uploads/2009/07/canvas-page.jpg" alt="canvas-page" width="600" height="435" /></p>
<h3>Step 2 - So Far So Good</h3>
<p>ok lets start some PHP, create two files &#8220;index.php&#8221; , &#8220;config.php&#8221; and a folder &#8220;facebook&#8221;.  Download the client libs of your choice from <a href="http://wiki.developers.facebook.com/index.php/Client_Libraries">Facebook client libraries</a> . For this demo I’ll be using the <a href="http://wiki.developers.facebook.com/index.php/PHP">official PHP client</a>.</p>
<p>Extract the content of the php folder(from Facebook&#8217;s official php client) in folder facebook of your application.</p>
<p>paste the given code in your config.php file. Do not forget to change database settings and Facebook constants i.e API , Secret etc..</p>
<pre class="brush: php">
&lt;?php
// ** MySQL settings ** //
define(&#039;DB_NAME&#039;, &#039;quiz&#039;);    // The name of the database
define(&#039;DB_USER&#039;, &#039;root&#039;);     // Your MySQL username
define(&#039;DB_PASSWORD&#039;, &#039;&#039;); // ...and password
define(&#039;DB_HOST&#039;, &#039;localhost&#039;);    // 99% chance you won&#039;t need to change this value

// ** Facebook settings ** //
define(&#039;API_KEY&#039;, &#039;Your API&#039;); // Change this to a your Facebook API key.
define(&#039;SECRET&#039;, &#039;Your Secret Key&#039;); // Change this to a your Facebook secret key.
define(&#039;APP_NAME&#039;, &#039;Drum Your Dialogue Knowledge!&#039;); // Your application name
define(&#039;APP_URL&#039;, &#039;dialoguedrums&#039;);// App. url after the http://apps.facebook.com/

/* That&#039;s all, stop editing! Happy Facebooking :D. */
require_once(&#039;facebook/facebook.php&#039;);
mysql_connect(DB_HOST, DB_USER,DB_PASSWORD);
@mysql_select_db(DB_NAME) or die( &quot;Unable to select database&quot;);
?&gt;
</pre>
<h3>Step 3 - Give Me More</h3>
<p>Before creating Facebook quiz application lets create a simple PHP quiz first.</p>
<pre class="brush: php">
&lt;?php
session_start();
require(&#039;config.php&#039;);

if($_GET[&#039;act&#039;] == &#039;&#039;)
{
	$quizQuery	= &quot;SELECT * FROM questions&quot;;

	$quizResult	= mysql_query($quizQuery);
	$rowCount	= mysql_num_rows($quizResult);

	$_SESSION[&#039;totalQuestions&#039;]	= $rowCount;

	if($rowCount &amp;amp;amp;amp;amp;gt;= 1)
	{
		echo &#039;&lt;form action=&quot;?act=answer&quot; method=&quot;post&quot;&gt;&#039;;
		while($quizData	= mysql_fetch_assoc($quizResult))
		{
			echo &quot;&lt;h2&gt;$quizData[quiz]&lt;/h2&gt;&quot;;
			$answerQuery	= &quot;SELECT * FROM answers WHERE question_id=&#039;$quizData[id]&#039;&quot;;
			$answerResult	= mysql_query($answerQuery);
			if(mysql_num_rows($answerResult) &gt;= 1)
			{
				while($answerData = mysql_fetch_assoc($answerResult))
				{
					echo &quot;&lt;input type=&#039;radio&#039; name=&#039;answer-$quizData[id]&#039; value=&#039;$answerData[id]&#039;&gt;&amp;nbsp;$answerData[answer]&lt;br/&gt;&quot;;
				}
			}
		}
		echo &quot;&lt;br/&gt;&lt;input type=&#039;submit&#039; value=&#039;Submit&#039; name=&#039;sny-fb-app&#039;/&gt;&quot;;
		echo &#039;&lt;/form&gt;&#039;;
	}
}
elseif(isset($_POST[&#039;sny-fb-app&#039;]) &amp;&amp; $_GET[&#039;act&#039;]==&#039;answer&#039;)
{
	$quizIdQuery	= &#039;SELECT id FROM questions&#039;;
	$quizIdResult	= mysql_query($quizIdQuery);
	$rowCount		= mysql_num_rows($quizIdResult);
	if($rowCount &gt;= 1)
	{
		while($quizIdData = mysql_fetch_assoc($quizIdResult))
		{
			$answerId	= (int)$_POST[&#039;answer-&#039; . $quizIdData[&#039;id&#039;]];
			if(!empty($answerId))
			{
				$answerCheckQuery	= &quot;SELECT correct FROM answers WHERE id=$answerId&quot;;
				$answerCheckResult	= mysql_query($answerCheckQuery);
				$correctAnswers	= 0;
				if(mysql_num_rows($answerCheckResult) &amp;amp;amp;amp;amp;gt;= 1)
				{
					$answerCheckData	= mysql_fetch_row($answerCheckResult);
					if($answerCheckData[0]===&#039;yes&#039;)
					{
						$correctAnswers++;
					}
				}
			}
		}
		$percentage	= $correctAnswers/$rowCount * 100;
	}
	echo $percentage.&#039;%&#039;;
}
?&gt;;
</pre>
<div id="attachment_268" class="wp-caption alignnone" style="width: 610px"><img src="http://mypaaji.com/wp-content/uploads/2009/07/php-application.jpg" alt="php-application" title="php-application" width="600" height="741" class="alignnone size-full wp-image-265" /><p class="wp-caption-text">Our Plain and Simple PHP Application</p></div>
<h3>Step 4 - Rock n Roll</h3>
<p>Yes time for Facebook API integration. Create an object for Facebook API and now you are ready to interact with it.</p>
<pre class="brush: php">
$fb = new Facebook(API_KEY, SECRET);
</pre>
<p>Our application can be accessed from Facebook only. Nobody can access it directly like http://yourhost.com/youFbApplication/ for that we can use <strong>require_frame()</strong> function of Facebook API.</p>
<pre class="brush: php">
$fb-&gt;require_frame();
</pre>
<p><strong>require_login()</strong> function can be used to force user to login firs if not logged in already, function returns ID of the logged in user.</p>
<pre class="brush: php">
$userId = $fb-&gt;require_login();
</pre>
<p>ok if we want to Invite friends functionality we can use FQL and FBML(Facebook Markup Language) for that</p>
<pre class="brush: php">
/*Multiple Friend Invitaion*/
	$fql = &#039;SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=&quot;&#039; .
			$userId . &#039;&quot;) AND has_added_app=1&#039;;
	$_friends = $fb-&gt;api_client-&gt;fql_query($fql);
	// Extract the user ID’s returned in the FQL request into a new array.
	$friends = array();
	if (is_array($_friends) &amp;&amp; count($_friends))
	{
		foreach ($_friends as $friend)
		{
			$friends[] = $friend[&#039;uid&#039;];
		}
	}
	// Convert the array of friends into a comma-delimeted string.
	$friends = implode(&#039;,&#039;, $friends);
	$content = &quot;&lt;fb:name uid=\&quot;&quot; . $userId . &quot;\&quot; firstnameonly=\&quot;true\&quot; shownetwork=\&quot;false\&quot;/&gt; has played &lt;a href=\&quot;http://apps.facebook.com/&quot; .
			APP_URL . &quot;/\&quot;&gt;&quot; . APP_NAME .
			&quot;&lt;/a&gt; and thought it&#039;s so cool even you should try it out!\n&quot; .
			&quot;&lt;fb:req-choice url=\&quot;&quot; . $fb-&gt;get_add_url() . &quot;\&quot; label=\&quot;Play &quot; . APP_NAME .
			&quot;\&quot;/&gt;&quot;;
	?&gt;
	&lt;fb:request-form action=&quot;?act=done&quot; method=&quot;post&quot; type=&quot;&lt;? echo APP_NAME; ?&gt;&quot; content=&quot;&lt;? echo
htmlentities($content, ENT_COMPAT, &#039;UTF-8&#039;); ?&gt;&quot;&gt;  &lt;fb:multi-friend-selector actiontext=&quot;Here are your friends who don&#039;t have &lt;? echo
APP_NAME ?&gt; yet. Invite whoever you want -it&#039;s free!&quot; exclude_ids=&quot;&lt;? echo
$friends; ?&gt;&quot; /&gt; &lt;/fb:request-form&gt;
</pre>
<h3>Step 5 - The Wall Story</h3>
<p>The <a href="http://wiki.developers.facebook.com/index.php/Feed.publishUserAction">Wall story request feature</a> is implemented as a popup using FBJS - the subset of javascript allowed on Facebook canvas pages. It is slightly more complex than that unfortunately - you need to create a feed template first to describe the format of the story that will appear on users newsfeeds.<br />
Go to the <a href="http://developers.facebook.com/tools.php?feed">template editor tool</a> to begin. We’ll create a simple feed that shows some images and invites people to try the quiz.<br />
<div id="attachment_270" class="wp-caption alignnone" style="width: 610px"><a href="http://developers.facebook.com/tools.php?feed"><img src="http://mypaaji.com/wp-content/uploads/2009/07/feed-template.jpg" alt="http://developers.facebook.com/tools.php?feed" title="feed-template" width="600" height="227" class="size-full wp-image-270" /></a><p class="wp-caption-text">http://developers.facebook.com/tools.php?feed</p></div></p>
<p><strong>Create a One Line Story template</strong></p>
<p>One line template code.</p>
<pre class="brush: text">
{*actor*} played {*app_name*} quiz.
</pre>
<p>Sample Template Data.</p>
<pre class="brush: text">
{ &quot;app_name&quot;:&quot;my Application&quot;, &quot;quiz_result&quot;:&quot;80%&quot;}
</pre>
<p><img src="http://mypaaji.com/wp-content/uploads/2009/07/one-line-feed.jpg" alt="one-line-feed" title="one-line-feed" width="600" height="330" class="alignnone size-full wp-image-271" /></p>
<p><strong>Create a Short Story template</strong></p>
<p>Short story template title code.</p>
<pre class="brush: html">
{*actor*} took the {*app_name*} quiz and got the result: {*quiz_result*}..
</pre>
<p><img src="http://mypaaji.com/wp-content/uploads/2009/07/story-feed.jpg" alt="story-feed" title="story-feed" width="600" height="439" class="alignnone size-full wp-image-272" /></p>
<p>Skip the create action link form and register the template bundle after it go to <a href="http://developers.facebook.com/tools.php?templates">Registered Template Console</a> .<br />
<img src="http://mypaaji.com/wp-content/uploads/2009/07/template-bundle.jpg" alt="template-bundle" title="template-bundle" width="600" height="243" class="alignnone size-full wp-image-274" /></p>
<h3>Step 6 - Mission Accomplished</h3>
<pre class="brush: php">
&lt;?php
session_start();
require(&#039;config.php&#039;);

$fb		= new Facebook(API_KEY, SECRET);
$fb		-&gt; require_frame();
$userId	= $fb -&gt; require_login();

if($_GET[&#039;act&#039;] == &#039;&#039;)
{
	$_SESSION[&#039;percentage&#039;]=&#039;&#039;;
	$quizQuery	= &quot;SELECT * FROM questions&quot;;

	$quizResult	= mysql_query($quizQuery);
	$rowCount	= mysql_num_rows($quizResult);

	if($rowCount &gt;= 1)
	{
		echo &#039;&lt;form action=&quot;?act=answer&quot; method=&quot;post&quot;&gt;&#039;;
		while($quizData	= mysql_fetch_assoc($quizResult))
		{
			echo &quot;&lt;h2&gt;$quizData[quiz]&lt;/h2&gt;&quot;;
			$answerQuery	= &quot;SELECT * FROM answers WHERE question_id=&#039;$quizData[id]&#039;&quot;;
			$answerResult	= mysql_query($answerQuery);
			if(mysql_num_rows($answerResult) &gt;= 1)
			{
				while($answerData = mysql_fetch_assoc($answerResult))
				{
					echo &quot;&lt;input type=&#039;radio&#039; name=&#039;answer-$quizData[id]&#039; value=&#039;$answerData[id]&#039;&gt;&amp;nbsp;$answerData[answer]&lt;br/&gt;&quot;;
				}
			}
		}
		echo &quot;&lt;br/&gt;&lt;input type=&#039;submit&#039; value=&#039;Submit&#039; name=&#039;sny-fb-app&#039;&gt;&quot;;
		echo &#039;&lt;/form&gt;&#039;;
	}
}
elseif(isset($_POST[&#039;sny-fb-app&#039;]) &amp;&amp; $_GET[&#039;act&#039;]==&#039;answer&#039;)
{
	$quizIdQuery	= &#039;SELECT id FROM questions&#039;;
	$quizIdResult	= mysql_query($quizIdQuery);
	$rowCount		= mysql_num_rows($quizIdResult);
	if($rowCount &gt;= 1)
	{
		while($quizIdData = mysql_fetch_assoc($quizIdResult))
		{
			$answerId	= (int)$_POST[&#039;answer-&#039; . $quizIdData[&#039;id&#039;]];
			if(!empty($answerId))
			{
				$answerCheckQuery	= &quot;SELECT correct FROM answers WHERE id=$answerId &quot;;
				$answerCheckResult	= mysql_query($answerCheckQuery);
				$correctAnswers	= 0;
				if(mysql_num_rows($answerCheckResult) &gt;= 1)
				{
					$answerCheckData	= mysql_fetch_row($answerCheckResult);
					if($answerCheckData[0]===&#039;yes&#039;)
					{
						$correctAnswers++;
					}
				}
			}
		}
		$percentage	= $correctAnswers/$rowCount * 100;
	}
	$_SESSION[&#039;percentage&#039;]	= $percentage;

	/*Multiple Friend Invitaion*/
	$fql = &#039;SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=&quot;&#039; .
			$userId . &#039;&quot;) AND has_added_app=1&#039;;
	$_friends = $fb-&gt;api_client-&gt;fql_query($fql);
	// Extract the user ID’s returned in the FQL request into a new array.
	$friends = array();
	if (is_array($_friends) &amp;&amp; count($_friends))
	{
		foreach ($_friends as $friend)
		{
			$friends[] = $friend[&#039;uid&#039;];
		}
	}
	// Convert the array of friends into a comma-delimeted string.
	$friends = implode(&#039;,&#039;, $friends);
	$content = &quot;&lt;fb:name uid=\&quot;&quot; . $userId . &quot;\&quot; firstnameonly=\&quot;true\&quot; shownetwork=\&quot;false\&quot;/&gt; has played &lt;a href=\&quot;http://apps.facebook.com/&quot; .
			APP_URL . &quot;/\&quot;&gt;&quot; . APP_NAME .
			&quot;&lt;/a&gt; and thought it&#039;s so cool even you should try it out!\n&quot; .
			&quot;&lt;fb:req-choice url=\&quot;&quot; . $fb-&gt;get_add_url() . &quot;\&quot; label=\&quot;Play &quot; . APP_NAME .
			&quot;\&quot;/&gt;&quot;;
	?&gt;
	&lt;fb:request-form action=&quot;?act=done&quot; method=&quot;post&quot; type=&quot;&lt;? echo APP_NAME; ?&gt;&quot; content=&quot;&lt;? echo
htmlentities($content, ENT_COMPAT, &#039;UTF-8&#039;); ?&gt;&quot;&gt;  &lt;fb:multi-friend-selector actiontext=&quot;Here are your friends who don&#039;t have &lt;? echo
APP_NAME ?&gt; yet. Invite whoever you want -it&#039;s free!&quot; exclude_ids=&quot;&lt;? echo
$friends; ?&gt;&quot; /&gt; &lt;/fb:request-form&gt;
	&lt;?php
	/*Multiple Friend Invitaion END*/
}
elseif($_GET[&#039;act&#039;]==&#039;done&#039;)
{
	/*Wall Story Posting*/
	?&gt;

	&lt;h1&gt;Thanks For Playing &lt;a href=&quot;http://apps.facebook.com/&lt;?php echo APP_URL ?&gt;&quot;&gt;&lt;?php echo APP_NAME?&gt;&lt;/a&gt;&lt;/h1&gt;

	&lt;script type=&quot;text/javascript&quot;&gt;
var tpl_data={&quot;images&quot;:[{&quot;src&quot;:&quot;http://mypaaji.com/fb/images/kaalia_amitabh.jpg&quot;, &quot;href&quot;:&quot;http://apps.facebook.com/&lt;?php echo APP_URL ?&gt;&quot;},{&quot;src&quot;:&quot;http://mypaaji.com/fb/images/20pari.jpg&quot;,&quot;href&quot;:&quot;http://apps.facebook.com/&lt;?php echo APP_URL ?&gt;&quot;},{&quot;src&quot;:&quot;http://mypaaji.com/fb/images/lh11sholay.jpg&quot;, &quot;href&quot;:&quot;http://apps.facebook.com/&lt;?php echo APP_URL ?&gt;&quot;},{&quot;src&quot;:&quot;http://mypaaji.com/fb/images/mrindia.jpg&quot;,&quot;href&quot;:&quot;http://apps.facebook.com/&lt;?php echo APP_URL ?&gt;&quot;}],&quot;app_name&quot;:&quot;&lt;a href=&#039;http://apps.facebook.com/&lt;?php echo APP_URL ?&gt;&#039;&gt;&lt;?php echo APP_NAME ?&gt;&lt;/a&gt;&quot;,&quot;quiz_result&quot;:&quot;&lt;?php echo $_SESSION[&#039;percentage&#039;] ?&gt;&quot;};
var user_msg = {&quot;value&quot;:&quot;&quot;};
var share_msg = &quot;share with your friends&quot;;
Facebook.showFeedDialog(125793055361, tpl_data, &quot;&quot;, &quot;&quot;, null, share_msg, user_msg);
&lt;/script&gt;

	&lt;?php
	/*Wall Story Posting END*/
}
?&gt;
</pre>
<div class="tutorial_image"><a href="http://mypaaji.com/tut/facebookQuiz.zip"><img height="62" width="221" class="alignnone size-full wp-image-199" title="source" alt="source" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif"/></a><a href="http://apps.facebook.com/dialoguedrum/"><img height="62" width="221" class="alignnone size-full wp-image-198" title="demo" alt="demo" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif"/></a></div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/cEFGN3isPm8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/07/19/creating-a-facebook-application/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/07/19/creating-a-facebook-application/</feedburner:origLink></item>
		<item>
		<title>jQuery - Weather Widget</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/WfZnB_FNQd4/</link>
		<comments>http://mypaaji.com/index.php/2009/07/06/jquery-weather-widget/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 00:11:34 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=237</guid>
		<description><![CDATA[This code fetches data from a xml provided by google APIs, it requires jQuery and very little code of PHP. Last night my friend Prabodh asked something like this in java but unfortunately i don&#8217;t know JAVA so i did it in jQuery and PHP.
If you have any comment or ways to improve it, just [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This code fetches data from a xml provided by <a href="http://www.google.com/ig/api?weather">google APIs</a>, it requires <a href="http://jquery.com">jQuery</a> and very little code of <a href="http://php.net">PHP</a>. Last night my friend Prabodh asked something like this in java but unfortunately i don&#8217;t know JAVA so i did it in <a href="http://jquery.com">jQuery</a> and <a href="http://php.net">PHP</a>.<span id="more-237"></span></p>
<p><strong>If you have any comment or ways to improve it, just leave me a comment!</strong></p>
<div class="tutorial_image"><a href="http://mypaaji.com/wp-content/uploads/2009/07/weather-widget.zip"><img height="62" width="221" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif" alt="source" title="source" class="alignnone size-full wp-image-199"/></a><a href="http://mypaaji.com/tut/weather/"><img height="62" width="221" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif" alt="demo" title="demo" class="alignnone size-full wp-image-198"/></a></div>
<h3>Write Some PHP</h3>
<pre class="brush: php">
&lt;?php
header(&quot;content-type: text/xml&quot;);
$where = $_GET[&#039;where&#039;];
$xmlData = file_get_contents(&quot;http://www.google.com/ig/api?weather=$where&quot;);
echo $xmlData;
?&gt;
</pre>
<p>YUP, that&#8217;s it, you only have to do this much PHP :). Save it as <strong>google-weather.php</strong>.</p>
<h3>XML - Returned from above php script</h3>
<p><a href="http://mypaaji.com/wp-content/uploads/2009/07/_1246925063410.png"><img src="http://mypaaji.com/wp-content/uploads/2009/07/_1246925063410.png" alt="_1246925063410" title="_1246925063410" width="655" height="502" class="alignnone size-full wp-image-240" /></a></p>
<h3>HTML and CSS - Whatever</h3>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Weather Widget&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body{font-family:Georgia,&quot;Times New Roman&quot;,Times,serif;color:#FFFFFF;font-size:12px}
.rbroundbox { background: url(images/nt.gif) repeat; }
.rbtop div { background: url(images/tl.gif) no-repeat top left; }
.rbtop { background: url(images/tr.gif) no-repeat top right; }
.rbbot div { background: url(images/bl.gif) no-repeat bottom left; }
.rbbot { background: url(images/br.gif) no-repeat bottom right; }

/* height and width stuff, width not really nessisary. */
.rbtop div, .rbtop, .rbbot div, .rbbot {
height: 7px;
font-size: 1px;
}
.rbcontent { margin: 6px; display:none;}
.rbroundbox { float:left; margin: 1em auto; }
.tag{font-size:9px;
font-weight:bold;
letter-spacing:0.2em;
text-transform:uppercase;}
.data{color:#CCCCCC; font-weight:normal;margin-left:10px}
#error{color:crimson;}
&lt;/style&gt;
&lt;script src=&quot;jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function()
{
//jQuery Rocks
})
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;input type=&quot;text&quot; id=&quot;place&quot; /&gt;&lt;input type=&quot;button&quot; value=&quot;Weather Search&quot; id=&quot;submit&quot; /&gt;&lt;br /&gt;
	&lt;div class=&quot;rbroundbox&quot;&gt;
	&lt;div class=&quot;rbtop&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;
	&lt;div class=&quot;rbcontent tag&quot; id=&quot;error&quot;&gt;Sorry No Data Found!&lt;/div&gt;
		&lt;div class=&quot;rbcontent tag&quot; id=&quot;data&quot;&gt;
			&lt;span&gt;&lt;img src=&quot;&quot; id=&quot;icon&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
			&lt;span&gt;City -&lt;/span&gt;&lt;span class=&quot;data&quot; id=&quot;city&quot;&gt;&lt;/span&gt;&lt;br /&gt;
			&lt;span&gt;Date -&lt;/span&gt;&lt;span class=&quot;data&quot; id=&quot;date&quot;&gt;&lt;/span&gt;&lt;br /&gt;
			&lt;span&gt;Condition -&lt;/span&gt;&lt;span class=&quot;data&quot; id=&quot;condition&quot;&gt;&lt;/span&gt;&lt;br /&gt;
			&lt;span&gt;Temperature -&lt;/span&gt;&lt;span class=&quot;data&quot; id=&quot;tempC&quot;&gt;&lt;/span&gt;&lt;br /&gt;
			&lt;span&gt;Humidity -&lt;/span&gt;&lt;span class=&quot;data&quot; id=&quot;humidity&quot;&gt;&lt;/span&gt;&lt;br /&gt;
		&lt;/div&gt;&lt;!-- /rbcontent --&gt;
	&lt;div class=&quot;rbbot&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>jQuery - The Rockstar</h3>
<pre class="brush: js">
var childData	= function(selector, arg)
 {
 	return selector.find(arg).attr(&#039;data&#039;);
 }
var sendAjax =function(where){$(&#039;#data, #error&#039;).stop().hide(&#039;fast&#039;);
$.ajax({
   type: &quot;GET&quot;,
   data:&quot;where=&quot;+where,
   url: &quot;google-weather.php&quot;,//URL of our php page
    success: function(data){

    forecast	= $(data).find(&#039;forecast_information&#039;);
	cCondition	= $(data).find(&#039;current_conditions&#039;);

	city	= childData(forecast, &#039;city&#039;);
	if(city!=undefined)
	{
		date	= childData(forecast, &#039;forecast_date&#039;);

		condition	= childData(cCondition, &#039;condition&#039;);
		tempC	= childData(cCondition, &#039;temp_c&#039;);
		humidity	= childData(cCondition, &#039;humidity&#039;);
		icon	= childData(cCondition, &#039;icon&#039;);
		$(&#039;#city&#039;).text(city);
		$(&#039;#date&#039;).text(date);
		$(&#039;#condition&#039;).text(condition);
		$(&#039;#tempC&#039;).text(tempC+&#039; C&#039;);
		$(&#039;#humidity&#039;).text(humidity);
		$(&#039;#icon&#039;).attr({&#039;src&#039;:&#039;http://www.google.com&#039;+icon})
		$(&#039;#data&#039;).stop().show(&#039;fast&#039;);

	}
	else
	{
		$(&#039;#error&#039;).stop().show(&#039;fast&#039;);
	}

	}

 });
}
$(&#039;#submit&#039;).click(function()
{
where	= $(&#039;#place&#039;).val();
sendAjax(where);

})
</pre>
<p>That&#8217;s It :D&#8230;</p>
<p><strong>I know its not very well explained but what can I do, am very bad in explaining things and some times lazy too..</strong> <img src='http://mypaaji.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><strong>If you have any comment or ways to improve it, just leave me a comment!</strong></p>
<div class="tutorial_image"><a href="http://mypaaji.com/wp-content/uploads/2009/07/weather-widget.zip"><img height="62" width="221" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif" alt="source" title="source" class="alignnone size-full wp-image-199"/></a><a href="http://mypaaji.com/tut/weather/"><img height="62" width="221" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif" alt="demo" title="demo" class="alignnone size-full wp-image-198"/></a></div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/WfZnB_FNQd4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/07/06/jquery-weather-widget/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/07/06/jquery-weather-widget/</feedburner:origLink></item>
		<item>
		<title>jQuery Plugin - Multiple Select Transfer</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/a-j78UtOKvE/</link>
		<comments>http://mypaaji.com/index.php/2009/06/29/jquery-plugin-multiple-select-transfer/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 18:25:55 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[multitransfer]]></category>

		<category><![CDATA[option]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[select]]></category>

		<category><![CDATA[transfer]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=227</guid>
		<description><![CDATA[This plugin adds a functionality of transferring options from one select to another. I did it because
my friend Pranny needed something like this  .
If you have any comment or ways to improve it, just leave me a comment!


Setup
Nothing is easier to use. First include jQuery library, jTransfer js in the head of page(s) where [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This plugin adds a functionality of transferring options from one select to another. I did it because<br />
my friend Pranny needed something like this <img src='http://mypaaji.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>If you have any comment or ways to improve it, just leave me a comment!<br />
<br/><span id="more-227"></span></p>
<div class="tutorial_image"><a href="http://mypaaji.com/wp-content/uploads/2009/06/jtransfer.zip"><img width="221" height="62" class="alignnone size-full wp-image-199" title="source" alt="source" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif"/></a><a href="http://mypaaji.com/tut/jtransfer/"><img width="221" height="62" class="alignnone size-full wp-image-198" title="demo" alt="demo" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif"/></a></div>
<h3>Setup</h3>
<p>Nothing is easier to use. First include jQuery library, jTransfer js in the head of page(s) where you<br />
want to use jTransfer.<br />
you can download jquery from <a href="http://jquery.com" target="_blank">jQuery.com</a> .</p>
<pre class="brush: js">
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.transfer.js&quot;&gt;&lt;/script&gt;
</pre>
<h3>HTML</h3>
<pre class="brush: html">
&lt;select multiple=&quot;multiple&quot; id=&quot;select1&quot;&gt;
	&lt;option value=&quot;1&quot;&gt;Sunny&lt;/option&gt;
	&lt;option value=&quot;2&quot;&gt;Pranav&lt;/option&gt;
	&lt;option value=&quot;3&quot;&gt;Orkut&lt;/option&gt;
	&lt;option value=&quot;4&quot;&gt;Facebook&lt;/option&gt;
&lt;/select&gt;
&lt;a href=&quot;#&quot; id=&quot;addT&quot; class=&quot;button&quot;&gt;add &amp;amp;amp;amp;amp;amp;amp;raquo;&lt;/a&gt;
&lt;select multiple=&quot;multiple&quot; id=&quot;select2&quot;&gt;
&lt;/select&gt;
&lt;a href=&quot;#&quot; id=&quot;removeT&quot; class=&quot;button&quot;&gt;remove &amp;amp;amp;amp;amp;amp;amp;laquo;&lt;/a&gt;
</pre>
<h3>Css</h3>
<pre class="brush: css">
/*Plugin classes*/
.hidden{display:none;}
.added{color:#CCCCCC;}
/*End*/
</pre>
<h3>Initialize jTransfer</h3>
<pre class="brush: js">
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
$(&#039;#select1&#039;).transfer({
	to:&#039;#select2&#039;,//selector of second multiple select box
	addId:&#039;#addT&#039;,//add buttong id
	removeId:&#039;#removeT&#039; // remove button id
	});
});
&lt;/script&gt;
</pre>
<p>To customize the settings, you need to pass the values to jTransfer, like so:</p>
<pre class="brush: js">
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
$(&#039;#select1&#039;).transfer({
	to:&#039;#select2&#039;,//selector of second multiple select box
	searchId:&#039;#search&#039;,//id of search text, provide only if you want to enable searching
	dblClick:true,//true or false, activates double click transfer
	searchText:&#039;{count} options matching {keyword}&#039;,
	searchTextId:&#039;#searchText&#039;,//id to show search message, ex- matching 2 records
	addId:&#039;#addT&#039;,//add buttong id
	removeId:&#039;#removeT&#039;, // remove button id
	addAllId:&#039;#addAllT&#039;, // add all button id
	removeAllId:&#039;#removeAllT&#039;,// remove all button id
	tClass:&#039;added&#039;//class to be added when option tranfered to another select.
	});
});
&lt;/script&gt;
</pre>
<p><br/></p>
<div class="tutorial_image"><a href="http://mypaaji.com/wp-content/uploads/2009/06/jtransfer.zip"><img width="221" height="62" class="alignnone size-full wp-image-199" title="source" alt="source" src="http://mypaaji.com/wp-content/uploads/2009/06/source1.gif"/></a><a href="http://mypaaji.com/tut/jtransfer/"><img width="221" height="62" class="alignnone size-full wp-image-198" title="demo" alt="demo" src="http://mypaaji.com/wp-content/uploads/2009/06/demo1.gif"/></a></div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/a-j78UtOKvE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/06/29/jquery-plugin-multiple-select-transfer/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/06/29/jquery-plugin-multiple-select-transfer/</feedburner:origLink></item>
		<item>
		<title>Fair trial for kasav, no justice for Sarabjit?</title>
		<link>http://feedproxy.google.com/~r/mypaaji/FsMI/~3/AhWpiowLwi4/</link>
		<comments>http://mypaaji.com/index.php/2009/06/24/fair-trial-for-kasav-no-justice-for-sarabjit/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 00:25:01 +0000</pubDate>
		<dc:creator>Sny</dc:creator>
		
		<category><![CDATA[JLT]]></category>

		<category><![CDATA[fair]]></category>

		<category><![CDATA[justice]]></category>

		<category><![CDATA[kasav]]></category>

		<category><![CDATA[sarabjit]]></category>

		<category><![CDATA[trial]]></category>

		<guid isPermaLink="false">http://mypaaji.com/?p=222</guid>
		<description><![CDATA[


No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://mypaaji.com/wp-content/uploads/2009/06/svsk.png"><img class="size-full wp-image-223 aligncenter" title="svsk" src="http://mypaaji.com/wp-content/uploads/2009/06/svsk.png" alt="svsk" width="600" height="1000" /></a></p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/mypaaji/FsMI/~4/AhWpiowLwi4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://mypaaji.com/index.php/2009/06/24/fair-trial-for-kasav-no-justice-for-sarabjit/feed/</wfw:commentRss>
		<feedburner:origLink>http://mypaaji.com/index.php/2009/06/24/fair-trial-for-kasav-no-justice-for-sarabjit/</feedburner:origLink></item>
	</channel>
</rss>
