<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>php genious &#187; AJAX</title>
	<atom:link href="http://www.phpgenious.com/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpgenious.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Sep 2011 21:02:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Image Preview Script like Template Monster</title>
		<link>http://www.phpgenious.com/2010/04/image-preview-script-like-template-monster/</link>
		<comments>http://www.phpgenious.com/2010/04/image-preview-script-like-template-monster/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 06:50:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Image Preview]]></category>
		<category><![CDATA[Javascript image popup]]></category>
		<category><![CDATA[jquery image]]></category>
		<category><![CDATA[template monster like image preview]]></category>

		<guid isPermaLink="false">http://www.phpgenious.com/?p=407</guid>
		<description><![CDATA[Hello Friends !! Since last few days, I am looking for Image Preview Script like template monster. I was doing lots of googling to fing this type of script. I [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Friends !!</p>
<p>Since last few days, I am looking for Image Preview Script like template monster. I was doing lots of googling to fing this type of script.</p>
<p>I found one script from javascriptkit.com but its not browser compitible script. (Not working in Google Chrome and Safari). I was searching in goole to make this script compitible with all the browsers. But I wasn&#8217;t get any help. At that time, I decided to make such type of script.</p>
<p><span id="more-407"></span></p>
<p>After long research and modification, I got success to make such type of script which shows your image properly.I have made script which preview your image same like template monster .</p>
<p>Today I will provide you this script. <a href="http://www.phpgenious.com/test/mouseover-popup/example.html" target="_blank"><strong>Click here</strong></a> to see the Demo of this script.</p>
<p>For Download full source code, <strong>Click Below</strong> links or <a href="http://www.phpgenious.com/test/mouseover-popup.rar" target="_blank">Click Here</a><br />
<!--adsense#cronjob--></p>
<p>If you have any suggestion or any query regarding this script, then feel free to comment on this post.<br />
Thanks !!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpgenious.com/2010/04/image-preview-script-like-template-monster/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Change DIV height/width with body width/height using jQuery</title>
		<link>http://www.phpgenious.com/2010/04/change-div-heightwidth-with-body-widthheight-using-jquery/</link>
		<comments>http://www.phpgenious.com/2010/04/change-div-heightwidth-with-body-widthheight-using-jquery/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 11:59:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[set div with jquery]]></category>

		<guid isPermaLink="false">http://www.phpgenious.com/?p=398</guid>
		<description><![CDATA[Hello Friends !! SInce last few dyas, I am facing the problem that how can I change DIV height/width with body or browser height/width ? I want that DIV heoght [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Friends !!</p>
<p>SInce last few dyas, I am facing the problem that how can I change DIV height/width with body or browser height/width ? I want that DIV heoght is increase when browser heignt increase and decrease when browser height decrease.</p>
<p>In short I wnat my DIV size browser friendly. For this, I search many things in google and finally I found the solution by jQuery. In this post, I will give you code that how to change your DIV height/width with browser height/width veries.</p>
<p>First download latest <a href="http://docs.jquery.com/Downloading_jQuery">jQuery</a> file. After this make one DIV for which you want to change the height/width.<br />
<span id="more-398"></span></p>
<p>&lt;div id=&#8221;test&#8221; style=&#8221;background-color:#000;&#8221;&gt;&lt;/div&gt;</p>
<p>In above DIV, i give background color <strong>black</strong> so you can see the change. Now write below code in you <strong>head</strong> section.I am giveng you some code whcih use for this.</p>
<p><strong>$(window).width(); =&gt; </strong>It returns width of the body<strong> </strong></p>
<p><strong> </strong></p>
<p><strong>$(document).width(); =&gt; </strong>It returns width of the whole window<strong> </strong></p>
<p><strong> </strong></p>
<p><strong>$(window).height(); =&gt; </strong>It returns height of the body<strong> </strong></p>
<p><strong> </strong></p>
<p><strong>$(document).height(); =&gt;</strong> It returns height of the whole window</p>
<p>Now for an example you want the div height same as your body</p>
<p>then use below code. First make one div like</p>
<p><strong>&lt;div id=&#8221;test&#8221; style=&#8221;background-color:#000;&#8221;&gt;&lt;/div&gt;</strong> I set blacj background color because you can see the change.</p>
<p>Suppose in your web page, there is one header which height is 100px and you want the above div height after header. So follow below code. Put this code in <strong>head</strong> section.</p>
<div class="code">
<p>&lt;script language=&#8221;javascript&#8221;&gt;</p>
<p>$(document).ready(function(){</p>
<p>var height1 = $(document).height(); // height of full document</p>
<p>var height2 = $(&#8220;#header&#8221;).height(); // height of header</p>
<p>var height_diff = height1 &#8211;  height2 + &#8220;px&#8221;;</p>
<p>document.getElementById(&#8216;test&#8217;).style.height = height_diff; // Set the remaining height in <strong>test</strong> DIV.</p>
<p>});</p>
<p>&lt;/script&gt;</p>
</div>
<p>Thats it. You can also use span tag instead of div. You can set your DIV height/width as page resize. If you have any confusion or query about this than comment on this.</p>
<p>Thanks You !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpgenious.com/2010/04/change-div-heightwidth-with-body-widthheight-using-jquery/feed/</wfw:commentRss>
		<slash:comments>120</slash:comments>
		</item>
		<item>
		<title>Delete Record Using JQuery and PHP with Animation</title>
		<link>http://www.phpgenious.com/2009/03/delete-record-using-jquery-and-php-with-animation/</link>
		<comments>http://www.phpgenious.com/2009/03/delete-record-using-jquery-and-php-with-animation/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 13:25:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://www.phpgenious.com/?p=267</guid>
		<description><![CDATA[Hello Friends !! Today I will Give you code to delete records using JQuery and PHP with Animation effect. It is very simple to understand. First you have to download [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Friends !!</p>
<p>Today I will Give you code to delete records using JQuery and PHP with Animation effect.</p>
<p>It is very simple to understand. First you have to download jquery.js which is availble <a href="http://jquery.com/">HERE</a>.</p>
<p>After that copy this code in your PHP file and run it.<br />
<span id="more-267"></span><br />
<!--adsense#DeleteJQueryRecords--></p>
<div class="code">&lt;?php<br />
$mysql_hostname = &#8220;localhost&#8221;;<br />
$mysql_user = &#8220;root&#8221;;<br />
$mysql_password = &#8220;&#8221;;<br />
$mysql_database = &#8220;test&#8221;;</p>
<p>$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die(&#8220;Could not connect database&#8221;);<br />
mysql_select_db($mysql_database, $bd) or die(&#8220;Could not select database&#8221;);</p>
<p>if(isset($_GET['delete']))<br />
{</p>
<p>$query1 = &#8216;DELETE FROM test WHERE id = &#8216;.(int)$_GET['delete'];<br />
$result = mysql_query($query1,$bd);<br />
}<br />
?&gt;</p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243; /&gt;<br />
&lt;title&gt;Untitled Document&lt;/title&gt;<br />
&lt;script language=&#8221;javascript&#8221; type=&#8221;text/javascript&#8221; src=&#8221;js/jquery.js&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
$(document).ready(function() {<br />
$(&#8216;a.delete&#8217;).click(function(e) {<br />
e.preventDefault();</p>
<p>var parent = $(this).parent();</p>
<p>$.ajax(<br />
{<br />
type: &#8216;get&#8217;,<br />
url: &#8216;list.php&#8217;,<br />
data: &#8216;ajax=1&amp;delete=&#8217; + parent.attr(&#8216;id&#8217;).replace(&#8216;record-&#8217;,&#8221;),</p>
<p>beforeSend: function()<br />
{<br />
$(this).parents(&#8220;id&#8221;).animate({backgroundColor: &#8220;#fbc7c7&#8243; }, &#8220;fast&#8221;).animate({ opacity: &#8220;hide&#8221; }, &#8220;slow&#8221;);<br />
},<br />
success: function()<br />
{<br />
parent.slideUp(300,function() {<br />
parent.remove();<br />
});<br />
}<br />
});<br />
});<br />
});<br />
&lt;/script&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body&gt;<br />
&lt;form id=&#8221;frm_change_password&#8221; name=&#8221;frm_change_password&#8221; method=&#8221;post&#8221; action=&#8221;"&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;action&#8221; id=&#8221;action&#8221; value=&#8221;" /&gt;<br />
&lt;?php<br />
$query = &#8216;SELECT * FROM test ORDER BY name ASC&#8217;;<br />
$result = mysql_query($query,$bd);<br />
while($row = mysql_fetch_assoc($result))</p>
<p>{<br />
echo &#8216;&lt;div class=&#8221;record&#8221; id=&#8221;record-&#8217;,$row['id'],&#8217;&#8221;&gt;<br />
&lt;a href=&#8221;?delete=%27,$row%5B%27id%27%5D,%27&#8243; class=&#8221;delete&#8221;&gt;Delete&lt;/a&gt;<br />
&lt;strong&gt;&#8217;,$row['name'],&#8217;&lt;/strong&gt;</p>
<p>&lt;/div&gt;&#8217;;<br />
}<br />
?&gt;</p>
<p>&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></div>
<p>Enjoy the jQuery effect.</p>
<p>If you like this post then comment on this.If you have any query related to PHP then you can also tell me.</p>
<p>I will try my best to solve your problem.</p>
<p>Thanks&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpgenious.com/2009/03/delete-record-using-jquery-and-php-with-animation/feed/</wfw:commentRss>
		<slash:comments>80</slash:comments>
		</item>
		<item>
		<title>Username Availability Chacker in AJAX and PHP using jQuery</title>
		<link>http://www.phpgenious.com/2009/02/username-availability-chacker-in-ajax-and-php-using-jquery/</link>
		<comments>http://www.phpgenious.com/2009/02/username-availability-chacker-in-ajax-and-php-using-jquery/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 06:19:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.phpgenious.com/?p=157</guid>
		<description><![CDATA[Hello Friend ! Yesterday when i was searching, i was found some new thing. In this post i will show yuo that how to make afancy Username availability checker using [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Friend !</p>
<p>Yesterday when i was searching, i was found some new thing.</p>
<p>In this post i will show yuo that how to make afancy Username availability checker using AJAX and PHP wiyh jQuery.</p>
<p>If you are looking for such kind of effect for checking username availability then defenatelyÂ  this post helps you.</p>
<p>Now let&#8217;s see hoe to check username using AJAX and PHP with jQyery.</p>
<p>First of all, write this code in your html code:</p>
<div class="code">
<pre class="prettyprint" style="overflow: auto;"><span class="tag">&lt;div &gt;</span><span class="pln">
Â User Name : </span><span class="tag">&lt;input </span><span class="atn">name</span><span class="tag">=</span><span class="atv">"username"</span><span class="tag"> </span><span class="atn">type</span><span class="tag">=</span><span class="atv">"text"</span><span class="tag"> </span><span class="atn">id</span><span class="tag">=</span><span class="atv">"username"</span><span class="tag"> </span><span class="atn">value</span><span class="tag">=</span><span class="atv">""</span><span class="tag"> </span><span class="atn">maxlength</span><span class="tag">=</span><span class="atv">"15"</span><span class="tag"> </span><span class="atn">/</span><span class="tag">&gt;</span><span class="pln">
Â </span><span class="tag">&lt;span </span><span class="atn">id</span><span class="tag">=</span><span class="atv">"msgbox"</span><span class="tag"> </span><span class="atn">style</span><span class="tag">=</span><span class="embsrc"><span class="pun">"</span><span class="pln">display</span><span class="pun">:</span><span class="pln">none</span><span class="str">"</span></span><span class="tag">&gt;&lt;/span&gt;</span><span class="pln">
</span><span class="tag">&lt;/div&gt;</span></pre>
</div>
<p>In this code, &#8220;span&#8221; with id &#8220;msgbox&#8221; shows the username availability message from ajax.<br />
<span id="more-157"></span><br />
<strong>CSS Code :</strong></p>
<div class="code">.messagebox{<br />
position:absolute;<br />
width:100px;<br />
margin-left:30px;<br />
border:1px solid #c93;<br />
background:#ffc;<br />
padding:3px;<br />
}<br />
.messageboxok{<br />
position:absolute;<br />
width:auto;<br />
margin-left:30px;<br />
border:1px solid #349534;<br />
background:#C9FFCA;<br />
padding:3px;<br />
font-weight:bold;<br />
color:#008000;<br />
}<br />
.messageboxerror{<br />
position:absolute;<br />
width:auto;<br />
margin-left:30px;<br />
border:1px solid #CC0000;<br />
background:#F7CBCA;<br />
padding:3px;<br />
font-weight:bold;<br />
color:#CC0000;<br />
}</div>
<p>Iâ€™ve defined three different class for three type of different message class â€œmessageboxâ€ for â€œcheckingâ€¦.â€ message, â€œmessageboxokâ€ and â€œmessageboxerrorâ€ class for displaying username available and not available messages.</p>
<p><strong>Javascript code:</strong></p>
<p>First of all you have to download jQuery library and include like this :</p>
<div class="code">
<pre class="prettyprint" style="overflow: auto;"><span class="tag">&lt;script </span><span class="atn">src</span><span class="tag">=</span><span class="atv">"jquery.js"</span><span class="tag"> </span><span class="atn">type</span><span class="tag">=</span><span class="atv">"text/javascript"</span><span class="tag"> </span><span class="atn">language</span><span class="tag">=</span><span class="atv">"javascript"</span><span class="tag">&gt;&lt;/script&gt;</span></pre>
</div>
<p>And when the focus is moved from the textbox of username the following function is called which call â€œuser_availability.phpâ€ through ajax and display the appropriate message with fading effect.</p>
<div class="code">
<pre class="prettyprint" style="overflow: auto;"><span class="pln">$</span><span class="pun">(</span><span class="str">"#username"</span><span class="pun">).</span><span class="pln">blur</span><span class="pun">(</span><span class="kwd">function</span><span class="pun">()</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
Â </span><span class="com">//remove all the class add the messagebox classes and start fading</span><span class="pln">
Â $</span><span class="pun">(</span><span class="str">"#msgbox"</span><span class="pun">).</span><span class="kwd">removeClass</span><span class="pun">().</span><span class="kwd">addClass</span><span class="pun">(</span><span class="str">'messagebox'</span><span class="pun">).</span><span class="pln">text</span><span class="pun">(</span><span class="str">'Checking...'</span><span class="pun">).</span><span class="pln">fadeIn</span><span class="pun">(</span><span class="str">"slow"</span><span class="pun">);</span><span class="pln">
Â </span><span class="com">//check the username exists or not from ajax</span><span class="pln">
Â $</span><span class="pun">.</span><span class="kwd">post</span><span class="pun">(</span><span class="str">"user_availability.php"</span><span class="pun">,{</span><span class="pln"> user_name</span><span class="pun">:</span><span class="pln">$</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">).</span><span class="pln">val</span><span class="pun">()</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">,</span><span class="kwd">function</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln">
Â </span><span class="pun">{</span><span class="pln">
Â  </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">data</span><span class="pun">==</span><span class="str">'no'</span><span class="pun">)</span><span class="pln"> </span><span class="com">//if username not avaiable</span><span class="pln">
Â  </span><span class="pun">{</span><span class="pln">
Â  Â $</span><span class="pun">(</span><span class="str">"#msgbox"</span><span class="pun">).</span><span class="pln">fadeTo</span><span class="pun">(</span><span class="lit">200</span><span class="pun">,</span><span class="lit">0</span><span class="pun">.</span><span class="lit">1</span><span class="pun">,</span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="com">//start fading the messagebox</span><span class="pln">
Â  Â </span><span class="pun">{</span><span class="pln">
Â  Â  </span><span class="com">//add message and change the class of the box and start fading</span><span class="pln">
Â  Â  $</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">).</span><span class="pln">html</span><span class="pun">(</span><span class="str">'This User name Already exists'</span><span class="pun">).</span><span class="kwd">addClass</span><span class="pun">(</span><span class="str">'messageboxerror'</span><span class="pun">).</span><span class="pln">fadeTo</span><span class="pun">(</span><span class="lit">900</span><span class="pun">,</span><span class="lit">1</span><span class="pun">);</span><span class="pln">
Â  Â </span><span class="pun">});</span><span class="pln">
Â  </span><span class="pun">}</span><span class="pln">
Â  </span><span class="kwd">else</span><span class="pln">
Â  </span><span class="pun">{</span><span class="pln">
Â  Â $</span><span class="pun">(</span><span class="str">"#msgbox"</span><span class="pun">).</span><span class="pln">fadeTo</span><span class="pun">(</span><span class="lit">200</span><span class="pun">,</span><span class="lit">0</span><span class="pun">.</span><span class="lit">1</span><span class="pun">,</span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> Â </span><span class="com">//start fading the messagebox</span><span class="pln">
Â  Â </span><span class="pun">{</span><span class="pln">
Â  Â  </span><span class="com">//add message and change the class of the box and start fading</span><span class="pln">
Â  Â  $</span><span class="pun">(</span><span class="kwd">this</span><span class="pun">).</span><span class="pln">html</span><span class="pun">(</span><span class="str">'Username available to register'</span><span class="pun">).</span><span class="kwd">addClass</span><span class="pun">(</span><span class="str">'messageboxok'</span><span class="pun">).</span><span class="pln">fadeTo</span><span class="pun">(</span><span class="lit">900</span><span class="pun">,</span><span class="lit">1</span><span class="pun">);</span><span class="pln">
Â  Â </span><span class="pun">});</span><span class="pln">
Â  </span><span class="pun">}</span><span class="pln">
Â </span><span class="pun">});</span><span class="pln">
</span><span class="pun">});</span></pre>
</div>
<p align="justify">As you can see in the first line, â€œallâ€ css class is removed from the div displaying the message and then â€œmessageboxâ€ class is added to that that element with adding the text â€œcheckingâ€ within the element and displaying with fading effect.</p>
<p align="justify">After that, ajax is used to call the PHP file, and when response is received through Ajax then jQuery is used to show the respective message-box with fading effects.</p>
<p align="justify"><strong>PHP Code :</strong></p>
<div class="code">
<pre class="prettyprint" style="overflow: auto;"><span class="com">//this varible contains the array of existing users</span><span class="pln">
$existing_users</span><span class="pun">=</span><span class="pln">array</span><span class="pun">('timir', 'ankur' ,'binoy','dhruv'</span><span class="pun">);</span><span class="pln">
</span><span class="com">//value got from the get metho</span><span class="pln">
$user_name</span><span class="pun">=</span><span class="pln">$_POST</span><span class="pun">[</span><span class="str">'user_name'</span><span class="pun">];</span><span class="pln">
</span><span class="com">//checking weather user exists or not in $existing_users array</span><span class="pln">
</span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">in_array</span><span class="pun">(</span><span class="pln">$user_name</span><span class="pun">,</span><span class="pln"> $existing_users</span><span class="pun">))</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
Â </span><span class="com">//user name is not available</span><span class="pln">
Â </span><span class="kwd">echo</span><span class="pln"> </span><span class="str">"no"</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span><span class="pln">
</span><span class="kwd">else</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
Â  </span><span class="com">//username available i.e. user name doesn't exists in array</span><span class="pln">
Â  </span><span class="kwd">echo</span><span class="pln"> </span><span class="str">"yes"</span><span class="pun">;</span><span class="pln">
</span><span class="pun">}</span></pre>
</div>
<p>In the above PHP code, Iâ€™ve added four usernames in a array and then check weather that user exists or not in that array and print â€œyesâ€ or â€œnoâ€ accordingly. The response taken from ajax is used within JavaScript function to display the appropriate message.But, you can use database connection to check the the availability of username in your code.</p>
<p>First of all <a href="http://www.phpgenious.com/test/jquery.rar">DOWNLOAD</a> jQuery library.</p>
<p>If you want to see DEMO, <a href="http://www.phpgenious.com/test/">CLICK HERE</a></p>
<p>Please comment on this Post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpgenious.com/2009/02/username-availability-chacker-in-ajax-and-php-using-jquery/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Example of AJAX and PHP</title>
		<link>http://www.phpgenious.com/2009/02/example-of-ajax-and-php/</link>
		<comments>http://www.phpgenious.com/2009/02/example-of-ajax-and-php/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 15:11:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://www.phpgenious.com/?p=92</guid>
		<description><![CDATA[Hello Friends ! Here I explain one Example how AJAX used in PHP ? First create a database displayed below: id FirstName LastName Age Hometown Job 1 Peter Griffin 41 [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Friends !</p>
<p>Here I explain one Example how AJAX used in PHP ?<strong></strong></p>
<h2>First create a database displayed below:</h2>
<table border="0">
<tbody>
<tr>
<th>id</th>
<th>FirstName</th>
<th>LastName</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>
<tr>
<td>1</td>
<td>Peter</td>
<td>Griffin</td>
<td>41</td>
<td>Quahog</td>
<td>Brewery</td>
</tr>
<tr>
<td>2</td>
<td>Lois</td>
<td>Griffin</td>
<td>40</td>
<td>Newport</td>
<td>Piano Teacher</td>
</tr>
<tr>
<td>3</td>
<td>Joseph</td>
<td>Swanson</td>
<td>39</td>
<td>Quahog</td>
<td>Police Officer</td>
</tr>
<tr>
<td>4</td>
<td>Glenn</td>
<td>Quagmire</td>
<td>41</td>
<td>Quahog</td>
<td>Pilot</td>
</tr>
</tbody>
</table>
<h2>Then You have to create HTML form:</h2>
<pre><strong><em>&lt;html&gt;
&lt;head&gt;
&lt;script src="selectuser.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;</em></strong></pre>
<pre><strong><em>&lt;form&gt;
Select a User:
&lt;select name="users" onchange="showUser(this.value)"&gt;
&lt;option value="1"&gt;Peter Griffin&lt;/option&gt;
&lt;option value="2"&gt;Lois Griffin&lt;/option&gt;
&lt;option value="3"&gt;Glenn Quagmire&lt;/option&gt;
&lt;option value="4"&gt;Joseph Swanson&lt;/option&gt;
&lt;/select&gt;
&lt;/form&gt;</em></strong></pre>
<pre><strong><em>&lt;p&gt;
&lt;div id="txtHint"&gt;&lt;b&gt;User info will be listed here.&lt;/b&gt;&lt;/div&gt;
&lt;/p&gt;</em></strong></pre>
<pre><strong><em>&lt;/body&gt;
&lt;/html&gt;</em></strong></pre>
<p><span id="more-92"></span></p>
<p>Let Me Explained :</p>
<p><strong>The HTML Form</strong> :</p>
<p>As you can see it is just a simple HTML form with a drop down box called  &#8220;users&#8221; with names and the &#8220;id&#8221; from the database as option values.</p>
<p>The paragraph below the form contains a div called &#8220;txtHint&#8221;. The div is used  as a placeholder for info retrieved from the web server.</p>
<p>When the user selects data, a function called &#8220;showUser()&#8221; is executed.  The execution of the function is triggered by the &#8220;onchange&#8221; event.</p>
<p>In other  words: Each time the user changes the value in the drop down box, the function  showUser() is called.</p>
<h2>Javascript used in AJAX</h2>
<p>This javascript saved as&#8217;<strong>selectuser.js</strong>&#8216;.</p>
<pre><strong><em>var xmlHttp;</em></strong></pre>
<pre><strong><em>function showUser(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="getuser.php";
url=url+"?q="+str;
url=url+"&amp;sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}</em></strong></pre>
<pre><strong><em>function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
 }
}</em></strong></pre>
<pre><em><strong>function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}</strong>
</em></pre>
<p><strong>The showUser() Function</strong></p>
<p>If an item in the drop down box is selected the function  executes the following:</p>
<ol>
<li>Calls on the GetXmlHttpObject function to create an XMLHTTP object</li>
<li>Defines the url (filename) to send to the server</li>
<li>Adds a parameter (q) to the url with the content of the dropdown box</li>
<li>Adds a random number to prevent the server from using a cached file</li>
<li>Call stateChanged when a change is triggered</li>
<li>Opens the XMLHTTP object with the given url.</li>
<li>Sends an HTTP request to the server</li>
</ol>
<p>At Last You have to create one PHP page on which you want Result :</p>
<p>This PHP form shown below .</p>
<h2>The PHP Page</h2>
<p>The server page called by the JavaScript, is a simple PHP file called  &#8220;getuser.php&#8221;.</p>
<p>The page is written in PHP and uses a MySQL databse.</p>
<p>The code runs a SQL query against a database and returns the result as an HTML  table:</p>
<pre><strong><em>&lt;?php
$q=$_GET["q"];

$con = mysql_connect('localhost', 'peter', 'abc123');
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("ajax_demo", $con);

$sql="SELECT * FROM user WHERE id = '".$q."'";

$result = mysql_query($sql);

echo "&lt;table border='1'&gt;
&lt;tr&gt;
&lt;th&gt;Firstname&lt;/th&gt;
&lt;th&gt;Lastname&lt;/th&gt;
&lt;th&gt;Age&lt;/th&gt;
&lt;th&gt;Hometown&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;";

while($row = mysql_fetch_array($result))
 {
 echo "&lt;tr&gt;";
 echo "&lt;td&gt;" . $row['FirstName'] . "&lt;/td&gt;";
 echo "&lt;td&gt;" . $row['LastName'] . "&lt;/td&gt;";
 echo "&lt;td&gt;" . $row['Age'] . "&lt;/td&gt;";
 echo "&lt;td&gt;" . $row['Hometown'] . "&lt;/td&gt;";
 echo "&lt;td&gt;" . $row['Job'] . "&lt;/td&gt;";
 echo "&lt;/tr&gt;";
 }
echo "&lt;/table&gt;";

mysql_close($con);
?&gt;</em></strong></pre>
<p>When the query is sent from the JavaScript to the PHP page the following steps are occures:</p>
<ol>
<li>PHP opens a connection to a MySQL server</li>
<li>The &#8220;user&#8221; with the specified name is found</li>
<li>A table is created and the data is inserted and sent to the &#8220;txtHint&#8221;  	placeholder</li>
</ol>
<p>If you like my post then please comment on this.</p>
<p>Thanks&#8230;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpgenious.com/2009/02/example-of-ajax-and-php/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>Do You Know What is AJAX ?</title>
		<link>http://www.phpgenious.com/2009/02/do-you-know-what-is-ajax/</link>
		<comments>http://www.phpgenious.com/2009/02/do-you-know-what-is-ajax/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 14:50:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://www.phpgenious.com/?p=89</guid>
		<description><![CDATA[AJAX : Asynchronous Java And XML Ajax is a set of programming techniques or a particular approach to Web programming. These programming techniques involve being able to seamlessly update a [...]]]></description>
			<content:encoded><![CDATA[<p>AJAX : Asynchronous Java And XML</p>
<p>Ajax is a set of programming techniques or a particular approach to Web programming. These programming techniques involve being able to seamlessly update a Web page or a section of a Web application with input from the server, but without the need for an immediate page refresh. This doesn&#8217;t mean that the browser doesn&#8217;t make a connection to the Web server.</p>
<p>Ajax doesn&#8217;t have to use XML, and neither does it have to be asynchronous. Ajax applications can use XML, and they can be updated asynchronously. These are quite common tricks and techniques used to update the page, but they are not tied to these technologies.</p>
<p>Here are the technologies he specifically mentioned:</p>
<ul>
<li>XHTML and CSS</li>
<li>The Document Object Model (DOM)</li>
<li>JavaScript</li>
<li>XML and XSLT</li>
<li>The <code>XMLHttpRequest</code> object</li>
</ul>
<p>In reality, to create an application using Ajax techniques you need only three of these: XHTML, the DOM, and JavaScript. If you do any amount of development with Ajax techniques, though, you will almost certainly need to use all of the technologies at some point.</p>
<p>You&#8217;ll also probably need a server-side language to handle any interaction with the server. This is most typically one of the following three:</p>
<ul>
<li>PHP</li>
<li>ASP.NET (Visual Basic.Net/C#)</li>
<li>Java</li>
</ul>
<p>This is the Overview of AJAX.</p>
<p>In my Next Post I will write that how to use AJAX in PHP ?</p>
<p>Don&#8217;t Forget to leave comment.</p>
<p>Thanks&#8230;&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpgenious.com/2009/02/do-you-know-what-is-ajax/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
