<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Web wok &#187; scripts and tips</title>
	<atom:link href="http://webwok.wordpress.com/category/scripts-and-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://webwok.wordpress.com</link>
	<description>everyday recipes for the web cuisine</description>
	<lastBuildDate>Tue, 04 Aug 2009 09:35:22 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='webwok.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/0db2307c6544ac555349751a109889d6?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Web wok &#187; scripts and tips</title>
		<link>http://webwok.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://webwok.wordpress.com/osd.xml" title="Web wok" />
		<item>
		<title>Rotate and zoom images with Javascript</title>
		<link>http://webwok.wordpress.com/2008/11/17/rotate-and-zoom-images-with-javascript/</link>
		<comments>http://webwok.wordpress.com/2008/11/17/rotate-and-zoom-images-with-javascript/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 12:11:38 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[scripts and tips]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=98</guid>
		<description><![CDATA[A Javascript script to rotate and zoom images using the canvas element.
Installation
in the BODY of your html page insert the commands which will trigger the transformations and the image you want to rotate, embedded in a canvas element:
&#60;body onload="CanvasOnload()"&#62;
&#60;h1&#62;Image rotate and zoom&#60;/h1&#62;
    &#60;span style="text-align: center; width: 65px"&#62;
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=98&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A Javascript script to rotate and zoom images using the <a href="http://en.wikipedia.org/wiki/Canvas_(HTML_element)" target="_blank">canvas element</a>.</p>
<p><strong>Installation</strong></p>
<p>in the BODY of your html page insert the commands which will trigger the transformations and the image you want to rotate, embedded in a canvas element:</p>
<pre>&lt;<span class="start-tag">body</span><span class="attribute-name"> onload</span>=<span class="attribute-value">"CanvasOnload()"</span>&gt;</pre>
<pre>&lt;<span class="start-tag">h1</span>&gt;Image rotate and zoom&lt;/<span class="end-tag">h1</span>&gt;
    &lt;<span class="start-tag">span</span><span class="attribute-name"> style</span>=<span class="attribute-value">"text-align: center; width: 65px"</span>&gt;
        &lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"javascript: location.href = 'index.html'" </span><span class="attribute-name">style</span>=<span class="attribute-value">"text-decoration: none"</span>&gt;
            &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"reset.png" </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Reset the image" </span><span class="attribute-name">border</span>=<span class="attribute-value">"0" </span><span class="error"><span class="attribute-name">/</span></span>&gt;
        &lt;/<span class="end-tag">a</span>&gt;
    &lt;/<span class="end-tag">span</span>&gt;

&lt;<span class="start-tag">p</span>&gt;
	rotate:
	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"0°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(0);"</span>&gt;</pre>
<pre>	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"90°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(90);"</span>&gt;
	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"180°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(180);"</span>&gt;
	&lt;<span class="start-tag">input</span><span class="attribute-name"> type</span>=<span class="attribute-value">"button" </span><span class="attribute-name">value</span>=<span class="attribute-value">"-90°" </span><span class="attribute-name">onclick</span>=<span class="attribute-value">"rotate(-90);"</span>&gt;
&lt;/<span class="end-tag">p</span>&gt;

&lt;<span class="start-tag">div</span>&gt;
    &lt;<span class="start-tag">span</span><span class="attribute-name"> style</span>=<span class="attribute-value">"text-align: center; width: 65px"</span>&gt;
        &lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"#"
           </span><span class="attribute-name">onmousedown</span>=<span class="attribute-value">"mousedown = true; ZoomOut(document.getElementById('myimage'))"
           </span><span class="attribute-name">onmouseout</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">onmouseup</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">style</span>=<span class="attribute-value">"text-decoration: none"</span>&gt;
            &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"minus.jpg" </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Zoom out" </span><span class="attribute-name">border</span>=<span class="attribute-value">"0" </span><span class="error"><span class="attribute-name">/</span></span>&gt;
        &lt;/<span class="end-tag">a</span>&gt;</pre>
<pre>    &lt;/<span class="end-tag">span</span>&gt;
    &lt;<span class="start-tag">span</span><span class="attribute-name"> style</span>=<span class="attribute-value">"text-align: center; width: 65px"</span>&gt;
        &lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"#"
           </span><span class="attribute-name">onmousedown</span>=<span class="attribute-value">"mousedown = true; ZoomIn(document.getElementById('myimage'))"
           </span><span class="attribute-name">onmouseup</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">onmouseout</span>=<span class="attribute-value">"mousedown = false"
           </span><span class="attribute-name">style</span>=<span class="attribute-value">"text-decoration: none"</span>&gt;
            &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"plus.jpg" </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Zoom in" </span><span class="attribute-name">border</span>=<span class="attribute-value">"0" </span><span class="error"><span class="attribute-name">/</span></span>&gt;
        &lt;/<span class="end-tag">a</span>&gt;
    &lt;/<span class="end-tag">span</span>&gt;
&lt;/<span class="end-tag">div</span>&gt;

&lt;<span class="start-tag">canvas</span><span class="attribute-name"> id</span>=<span class="attribute-value">"ff_canvas" </span><span class="attribute-name">width</span>=<span class="attribute-value">"159" </span><span class="attribute-name">height</span>=<span class="attribute-value">"198"</span>&gt;
    &lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"/js-tests/rotateImage/fashionable.jpg"
         </span><span class="attribute-name">alt</span>=<span class="attribute-value">"Zend"
         </span><span class="attribute-name">width</span>=<span class="attribute-value">"159"
         </span><span class="attribute-name">height</span>=<span class="attribute-value">"198"
         </span><span class="attribute-name">id</span>=<span class="attribute-value">"myimage"
         </span><span class="attribute-name">style</span>=<span class="attribute-value">"margin-left: 50px; position: absolute; top: 110px; left: 250px; cursor: hand" </span><span class="error"><span class="attribute-name">/</span></span>&gt;</pre>
<pre>&lt;/<span class="end-tag">canvas</span>&gt;
&lt;/body&gt;</pre>
<p>In the HEAD of your html page, you need to insert the references to your scripts:</p>
<pre>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript" </span><span class="attribute-name">src</span>=<span class="attribute-value">"imgRotateCanvas.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;
&lt;<span class="start-tag">script</span><span class="attribute-name"> language</span>=<span class="attribute-value">"javascript" </span><span class="attribute-name">src</span>=<span class="attribute-value">"imgZoomCanvas.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;</pre>
<p>This is the code in &#8220;imgRotateCanvas.js&#8221;:</p>
<pre>/*Author: Val Cartei,  val.cartei@gmail.com.
Year:2008
Description: rotates an image embedded in a canvas element.

This script is an adaptation of a script by: Benoit Asselin | http://www.ab-d.fr. The original script can be found at:
The JavaScript Source!! http://javascript.internet.com
*/

/**
*function: rotate
* @param int p_deg - the degrees of the rotation (e.g. -90,180,270,0).
*/
function rotate(p_deg) {
	if(document.getElementById('ff_canvas')) {
		/*
		Ok!: Firefox 2, Safari 3, Opera 9.5b2
		No: Opera 9.27
		*/
		var image = document.getElementById('myimage');
		var canvas = document.getElementById('ff_canvas');
		var canvasContext = canvas.getContext('2d');

		switch(p_deg) {
			default :
			case 0 :
				canvas.setAttribute('width', image.width);
				canvas.setAttribute('height', image.height);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, 0, 0);
				break;
			case 90 :
				canvas.setAttribute('width', image.height);
				canvas.setAttribute('height', image.width);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, 0, -image.height);
				break;
			case 180 :
				canvas.setAttribute('width', image.width);
				canvas.setAttribute('height', image.height);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, -image.width, -image.height);
				break;
			case 270 :
			case -90 :
				canvas.setAttribute('width', image.height);
				canvas.setAttribute('height', image.width);
				canvasContext.rotate(p_deg * Math.PI / 180);
				canvasContext.drawImage(image, -image.width, 0);
				break;
		};

	} else {
		/*
		Ok!: MSIE 6 et 7
		*/
		var image = document.getElementById('myimage');
		switch(p_deg) {
			default :
			case 0 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=0)';
				break;
			case 90 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=1)';
				break;
			case 180 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2)';
				break;
			case 270 :
			case -90 :
				image.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation=3)';
				break;
		};

	};
};

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function() {
	var image = document.getElementById('myimage');
	var canvas = document.getElementById('ff_canvas');
	if(canvas.getContext) {
		image.style.visibility = 'hidden';
		image.style.position = 'absolute';
	} else {
		canvas.parentNode.removeChild(canvas);
	};

	rotate(0);
});</pre>
<p>This is the code in &#8220;imgZoomCanvas.js&#8221;:</p>
<pre>/*Author: Val Cartei,  val.cartei@gmail.com.
 Year:2008
 Description: rotates an image embedded in a canvas element.</pre>
<pre>This script is an adaptation of a script that can be found at:
 http://www.phpguru.org/downloads/image_rotate/rotate.html
 )*/
 &lt;!--
 mousedown = false; // An important global variable</pre>
<pre>/**
 * The zoom out function
 *
 * @param object obj The image object
 */
 function ZoomOut(obj)
 {
 if (document.all) {
 // In case the zoom property is not set
 if (obj.style.zoom == '') {
 obj.style.zoom = 1;
 }</pre>
<pre>if (parseFloat(obj.style.zoom) &lt;= 0.1) {
 return;
 }</pre>
<pre>obj.style.zoom = obj.style.zoom - 0.1;</pre>
<pre>if (mousedown) {
 setTimeout("ZoomOut(document.getElementById('" + obj.id + "'))", obj.height);
 }
 } else {
 var canvas  = document.getElementById('ff_canvas');
 var context = canvas.getContext('2d');</pre>
<pre>canvas.style.width = ((parseInt(canvas.style.width) ? parseInt(canvas.style.width) : obj.width) - 10) + 'px';
 canvas.style.height = ((parseInt(canvas.style.height) ? parseInt(canvas.style.height) : obj.height) - 10) + 'px';</pre>
<pre>if (mousedown) {
 setTimeout("ZoomOut(document.getElementById('" + obj.id + "'))", 50);
 }
 }
 }</pre>
<pre>/**
 * The zoom in function
 *
 * @param object obj The image object
 */
 function ZoomIn(obj)
 {
 if (document.all) {
 // In case the zoom property is not set
 if (obj.style.zoom == '') {
 obj.style.zoom = 1;
 }</pre>
<pre>// Lower limit is 0.1
 if (parseFloat(obj.style.zoom) &lt;= 0.1) {
 obj.style.zoom = 0.1;
 }</pre>
<pre>obj.style.zoom = Number(obj.style.zoom) + 0.1;</pre>
<pre>if (mousedown) {
 setTimeout("ZoomIn(document.getElementById('" + obj.id + "'))", obj.width);
 }
 } else {
 var canvas  = document.getElementById('ff_canvas');
 var context = canvas.getContext('2d');</pre>
<pre>canvas.style.width = ((parseInt(canvas.style.width) ? parseInt(canvas.style.width) : obj.width)+ 10) + 'px';
 canvas.style.height = ((parseInt(canvas.style.height) ? parseInt(canvas.style.height) : obj.height)+ 10) + 'px';</pre>
<pre>if (mousedown) {
 setTimeout("ZoomIn(document.getElementById('" + obj.id + "'))", 50);
 }
 }
 }</pre>
<pre>/**
 *
 */
 function Reset(img)
 {
 img.style.zoom = 1;
 img.rotation = -0.01;
 Rotate(img, 0.01);
 }</pre>
<pre>function CanvasOnload()
 {
 // IE
 if (document.all) {
 return;
 }</pre>
<pre>var canvas  = document.getElementById('ff_canvas');
 var context = canvas.getContext('2d');
 var img     = document.getElementById('myimage');</pre>
<pre>context.drawImage(img, 0, 0, img.width, img.height);
 }</pre>
<pre>/**
 * Shows the status of the rotation
 */
 function ShowStatus()
 {
 var img  = document.getElementById('myimage');
 var zoom = Number(img.style.zoom);</pre>
<pre>alert('Zoom factor: ' + (zoom ? zoom : 1) + '\nRotation factor: ' + (img.rotation ? img.rotation : '0') );
 }
 // --&gt;</pre>
<p>These are image files used. Put them in the root directory together with your html page and the .js scripts.</p>
<p>Zoom in:</p>
<p><a href="http://webwok.files.wordpress.com/2008/11/plus.jpg"><img class="alignnone size-full wp-image-99" title="plus" src="http://webwok.files.wordpress.com/2008/11/plus.jpg?w=60&#038;h=60" alt="plus" width="60" height="60" /></a></p>
<p>ZoomOut:</p>
<p><a href="http://webwok.files.wordpress.com/2008/11/minus.jpg"><img class="alignnone size-full wp-image-100" title="minus" src="http://webwok.files.wordpress.com/2008/11/minus.jpg?w=60&#038;h=60" alt="minus" width="60" height="60" /></a></p>
<p>and the sample image:</p>
<p><a href="http://webwok.files.wordpress.com/2008/11/fashionable.jpg"><img class="alignnone size-full wp-image-101" title="fashionable" src="http://webwok.files.wordpress.com/2008/11/fashionable.jpg?w=159&#038;h=198" alt="fashionable" width="159" height="198" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/98/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/98/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/98/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=98&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/11/17/rotate-and-zoom-images-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>

		<media:content url="http://webwok.files.wordpress.com/2008/11/plus.jpg" medium="image">
			<media:title type="html">plus</media:title>
		</media:content>

		<media:content url="http://webwok.files.wordpress.com/2008/11/minus.jpg" medium="image">
			<media:title type="html">minus</media:title>
		</media:content>

		<media:content url="http://webwok.files.wordpress.com/2008/11/fashionable.jpg" medium="image">
			<media:title type="html">fashionable</media:title>
		</media:content>
	</item>
		<item>
		<title>Jquery, Ajax forms, PHP and Mysql at the table</title>
		<link>http://webwok.wordpress.com/2008/11/03/jquery-ajax-forms-php-and-mysql-at-the-table/</link>
		<comments>http://webwok.wordpress.com/2008/11/03/jquery-ajax-forms-php-and-mysql-at-the-table/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 16:26:06 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[scripts and tips]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=88</guid>
		<description><![CDATA[Before starting, if you have PHP.x &#60; PHP.2, you need to put into your includes folder the library jsonwrapper (this encodes/decodes json objects).
Imagine you have a form to add an item to a shop and you want to create a new category for that shop without leaving that page.
One way to do it is to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=88&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em>Before starting, if you have PHP.x &lt; PHP.2, you need to put into your includes folder the library <a href="http://www.boutell.com/scripts/jsonwrapper.tar.gz" target="_blank">jsonwrapper </a>(this encodes/decodes json objects).</em></p>
<p>Imagine you have a form to add an item to a shop and you want to create a new category for that shop without leaving that page.</p>
<p>One way to do it is to have a link &#8220;add a new category&#8221; that when clicked, shows some input fields for adding the new category (e.g. name and description) and a button to submit these data.</p>
<p>When the button is clicked, javascript detects that you do not want to send the whole form, but instead it retrieves these fields and sends them as an Ajax request to the server. The php code on the server side will get the data, perform the request (adding the category) and return some data (e.g. the new category object) to the form. Javascript waits for the response and processes it.</p>
<p>This is the general idea, now let&#8217;s have a look at the code:</p>
<p><strong>Client-side: form.php</strong></p>
<p><em>in the HEAD insert javascript:</em></p>
<pre>&lt;script language="javascript" type="text/javascript" src="/assets/inc/jquery.js"&gt;&lt;/script&gt;

&lt;script language="javascript" type="text/javascript"&gt;
$(document).ready(function(){
$("ul#add-category-fields").hide();
$("a#add-category").click(function(){
     // Show subform to add a new category
     $("ul#add-category-fields").show();
     return false;
    });

    $("#btn-add-category").click(function(){
        $("#action").val("add category");
        $("#fm_edit").submit();
    });

    $("#fm_edit").submit(function(){
        if($("#action").val()=="add category")
        {
            //data to send
            var data={'catname': $("#catname").val(),'catdescription':$("#catdescription").val(),'add': "add"};
               $.post("manage_category.php",data, function(data) {
               if(data.idshopcategory&gt;0)
               {
                    $("new category has been added").insertAfter("a#add-category");
                    $("ul#add-category-fields").hide();//hide again the fields
               }else $("&lt;br&gt;&lt;p class='alert'&gt;something went wrong, category could not be added, try adding the new category from the Categories menu.&lt;/p&gt;").insertAfter("a#add-category");
               },"json");//end post
               $("#action").val("");
               return false;
        }else{
           //send to this page for edit item processing
            $("#action").val("");
           return true;
        }
   });
});//end document ready
&lt;/script&gt;</pre>
<p>The first line imports jquery library</p>
<p>The second script tag includes Ajax interaction:</p>
<p>it dynamically displays the fields in the form that will be sent as Ajax (hidden at the beginning) and when submitted it discriminates between the whole form and the sending of these fields (&#8216;action&#8217;).</p>
<p>it retrieves those fields within the form whose values we want to send to the server and encodes them as a json object.</p>
<p>it  sends a simple POST request to a server with the data as json.</p>
<p>it handles the response by veryifing the data sent back by the server. If successful, it modifies the form and add a positive feedback, otherwise it shows a negative feedback.</p>
<p>in the BODY:</p>
<p><em>within the HTML form</em></p>
<pre>....
 &lt;input type="hidden" id="action" name="action" value=""&gt;
.....

&lt;a href="#" id="add-category"&gt;add a new category&lt;/a&gt;
   &lt;ul id="add-category-fields"&gt;
        &lt;li&gt;&lt;label for="catname"&gt;&lt;/label&gt; &lt;input type="text" id="catname" name="catname" value=""&gt;&lt;/li&gt;
        &lt;li&gt;&lt;label for="catdescription"&gt;&lt;/label&gt; &lt;input type="text" id="catdescription" name="catdescription" value=""&gt;&lt;/li&gt;
        &lt;li&gt;&lt;input type="button" name="add category" id="btn-add-category" value="Add category"&gt;&lt;/li&gt;
  &lt;/ul&gt;</pre>
<p><strong>Server-side: manage_data.php</strong></p>
<p><em>PHP code:</em></p>
<pre>&lt;?php
//initialise vars
$new_record_id=0;$name="";$description="";
//json object returned to the calling page
$foo= array(
  'idshopcategory'  =&gt;0,
  'catname'   =&gt;0,
);

require_once incpath("/jsonwrapper/jsonwrapper.php"); //encode/decode json objects for AJAX calls
//get the data from the post request sent through javascript
if(!empty($_POST["add"])){

$name=$_POST['catname'];
$description=$_POST['catdescription'];
$new_record_id= $ShopCategory-&gt;newRecord($data);
}

 //json object returned to the calling page
$foo= array(
 'idshopcategory'  =&gt;1,
 'catname'   =&gt;$name,
'catdescription'   =&gt;$description,
);
// Now encode the array to JSON format
$json = json_encode($foo);
// encode array $json to JSON string
echo $json;
die();
?&gt;</pre>
<p>it creates an array of values to be returned</p>
<p>it encodes them as a json object (using json_encode as defined in the library jsonwrapper)</p>
<p>it sends the object to the page form.php.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=88&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/11/03/jquery-ajax-forms-php-and-mysql-at-the-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
		<item>
		<title>Dev and Live version of a WordPress site</title>
		<link>http://webwok.wordpress.com/2008/08/01/dev-live-wordpress-site/</link>
		<comments>http://webwok.wordpress.com/2008/08/01/dev-live-wordpress-site/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 11:52:05 +0000</pubDate>
		<dc:creator>3guineas</dc:creator>
				<category><![CDATA[CultureGeeks]]></category>
		<category><![CDATA[scripts and tips]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://webwok.wordpress.com/?p=58</guid>
		<description><![CDATA[Setting up the DEV and LIVE sites
Download the wordpress installation:  http://wordpress.org/download/.
In the dev and live servers, create a new empty folder in your websites roots.
Unzip the wordpress installation and copy the files in the newly created folders.
Set up the Apache&#8217;s virtual host for your dev and remote sites.
Create a new empty database i.e. culturegeeks in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=58&subd=webwok&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h2>Setting up the DEV and LIVE sites</h2>
<p>Download the wordpress installation:  <a class="external free" title="http://wordpress.org/download/" href="http://wordpress.org/download/"><strong><span style="color:#2583ad;">http://wordpress.org/download/</span></strong></a>.</p>
<p>In the dev and live servers, create a new empty folder in your websites roots.</p>
<p>Unzip the wordpress installation and copy the files in the newly created folders.</p>
<p>Set up the Apache&#8217;s virtual host for your dev and remote sites.</p>
<p>Create a new empty database i.e. culturegeeks in the dev server and another with the same name in your remote server.</p>
<p>Rename wp-example.php in wp-config.php.</p>
<p>Open wp-config.php and set the database settings so that if you are in your dev server you will connect to the dev database, otherwise it will connect to the remote database. In my case that&#8217;s what I got:</p>
<pre>switch($_SERVER['SERVER_NAME']){
 case '192.168.0.2':
 //dev site (fileserver)
 define('DB_USER', <em>'I am not gonna publish it here!'</em>);     // Your MySQL username
 define('DB_PASSWORD', <em>'I am not gonna publish it here!</em>'); // ...and password
 define('DB_HOST', '192.168.0.2');    // 99% chance you won't need to change this value
 break;
 default:
 //live site (dl320) //remote user:admin pwd:*g11eiKu9Y#E
 define('DB_USER', <em>'I am not gonna publish it here!'</em>);     // Your MySQL username
 define('DB_PASSWORD', <em>'I am not gonna publish it here!'</em>); // ...and password
 define('DB_HOST', '212.42.165.194');    // 99% chance you won't need to change this value
 break;
}
define('DB_NAME', 'culturegeeks');    // The name of the database</pre>
<p>Go to your dev website address and run the installation script:<br />
devyourwebsite/wp-admin/wp-install.php</p>
<p>This will set up the dev website.</p>
<p>Go to your live website address and run the installation script:<br />
devyourwebsite/wp-admin/wp-install.php</p>
<p>This will set up the live website.</p>
<p>You will be asked to give your blog a title and an email address. Next, you will be prompted with a username and password. Save these details, as you&#8217;ll require them when you access the website&#8217;s dashboard (admin area).</p>
<p>Set up the new site in Dreamweaver, where the local settings refer to the dev site and the remote settings your remote site&#8217;s ftp details. Test the connection is successful.</p>
<p>The two sites have now been initialized and should be exactly the same.</p>
<h2>Update your remote site</h2>
<p>Let&#8217;s say we want to make some changes to the look&amp;feel of the website. First, we will apply a new template to the dev site, twick it and then upload the changes to the live site.</p>
<p>First, download the new template. A range of free templates can be found at: <a href="http://themes.wordpress.net/">WordPress Theme Viewer</a></p>
<p>Unzip the package i.e. <em>dummy_Theme </em>into the themes/ folder of your dev site. </p>
<p>Go to your dev site&#8217;s dashboard, the new theme should appear as one of the available templates.</p>
<p>Make changes, i.e. change the logo (which can be found in the images/ folder of the theme).</p>
<p>In Dreamweaver, right-click on your chosen theme, theme/<em>dummy_Theme  </em>and click Put. This will automatically upload the folder in your live site.</p>
<p>Go to your remote site&#8217;s dashboard, the new theme should appear as one of the available templates.</p>
<p><strong>References</strong></p>
<p><a href="http://codex.wordpress.org/Main_Page">http://codex.wordpress.org/Main_Page</a> - wordpress guide</p>
<p><a href="http://codex.wordpress.org/Installing_WordPress#Detailed_Instructions">http://codex.wordpress.org/Installing_WordPress#Detailed_Instructions</a> - detailed installation&#8217;s instructions</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/webwok.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/webwok.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/webwok.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/webwok.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/webwok.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=webwok.wordpress.com&blog=4116722&post=58&subd=webwok&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://webwok.wordpress.com/2008/08/01/dev-live-wordpress-site/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2051d47514a46f13e86039bc1ddf531e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">3guineas</media:title>
		</media:content>
	</item>
	</channel>
</rss>