how to use json_encode function
<p>I am working with form builder where i saved the values into the database.  But now, I am having problem on fetching records from the database.  I saved the data by using php serialise function.  now I am trying to get the values by using 'json_encode'. i used this 'json_encode' into my php class but i dont know how to fetch those data to the appropriate box,i.e., i want the value of the 'input type=text' should print the value to that field and textarea value should append to the teaxtea field and so on.
Here is my php and jquery code;</p>

<pre><code>php

function viewForm($id=""){
    $form_items=$this-&gt;editorM-&gt;get($id);
    if(is_array($form_items) &amp;&amp; isset($form_items["id"])){
        $data=json_encode($form_items['forms']);
        echo $data;
        $html="
        &lt;div class='tab_content padded' style='display:block'&gt;
          &lt;div style='margin:0 auto;width:60%;text-align:center'&gt;
          &lt;form method='post' rel='ajaxed' action='".base_url()."admin/form_editor/saveForm' loadingDiv='loader_save_page' class='add_form'&gt; 

                  &lt;input type='hidden' name='form_id' value='$form_items[id]' class='id' /&gt;
                    &lt;div style='float:right' id='new_form'&gt;
                      &lt;div class='q_feedback' id='loader_save_page_c' style='float:right'&gt;&lt;/div&gt;
                      &lt;button type='submit' class='button save'&gt;Save Changes&lt;/button&gt;
                    &lt;/div&gt;
            &lt;/form&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        ";
        $this-&gt;load-&gt;view("admin/edit_page",array(
            "html"=&gt;$html
        ));
    }else{
        header("location: ".base_url()."admin/form_editor/");
    }       
}

function saveForm(){
    $data=$this-&gt;input-&gt;post("data");
    $form_id=$this-&gt;input-&gt;post('id');
    $modified_date=time();

    $ser=serialize($data);


    if(trim($form_id)!=""){
        if($this-&gt;editorM-&gt;save($form_id,array(
            "forms"=&gt;$ser,
            "modifieddate"=&gt;$modified_date,
            "modifiedby"=&gt;$this-&gt;_username
            )))
        }
    }
}


jquery

$(function(){
    var num=0;

    var templates={
        "btn":'&lt;div class="user_input button" rel="btn"&gt;'+
                    '&lt;input type="button" name="" value="" class="btn input_field"/&gt;',
        "text":'&lt;div class="user_input text_field" name="test" rel="text"&gt;'+
                        '&lt;input type="text" name="txt-{num}" value="" class=" label"'+
                        'placeholder="click here to edit" /&gt;' +
                        '&lt;input type="text" name="text" value="" /&gt;',
        "textarea":'&lt;div class="user_input textarea" rel="textarea"&gt;' +
                        '&lt;input type="text" name="caption-{num}" class="label" '+
                        'placeholder="click here to edit" /&gt;'+
                        '&lt;textarea name="textarea" /&gt;&lt;/textarea&gt;'

    },
    editor='&lt;ul class="edit_list"&gt;&lt;li class="delete"&gt;Remove&lt;/li&gt;&lt;/ul&gt;';

    function createTemplate(type){
        num++;
        return templates[type].replace("{num}",num)+editor+"&lt;/div&gt;";
    }

    $("ul.form_icons li").live("click",function(){
        var _this=$(this),type=_this.attr("rel");
        if(templates[type]){
            $("#new_form").before(createTemplate(type))
        }
    });

/*--------------------------FORM-----------------------------*/
    $('.add_form').live('submit', function(e){
        e.preventDefault();
            var form_id=$('.id').attr('value');

            var textInput=[],
            textArea=[],            
            radio=[],
            radioOption=[],     
            selectList=[],
            selectOption=[];

            //txtInput
            $('div.user_input').each(function(index, elm){              
                if($(this).is('.text_field')){
                    $(this).find(':input').each(function(index, elm){
                        textInput.push({caption:$(elm).val(),
                            name:($(elm).val()).replace(/\s+/g, '-').toLowerCase(), type:elm.type});
                    }); 

                    //textarea          
                }else if($(this).is('.textarea')){
                    $(this).find(':input, textarea').each(function(index, elm){
                        textArea.push({caption:$(elm).val(), 
                            name:($(elm).val()).replace(/\s+/g, '-').toLowerCase(), type:elm.type});
                    });
                {}
            });

            //posting data
            var data=[textInput, textArea, radio, selectList];  
            $.post(BASE_URL+'admin/form_editor/saveForm', {data:JSON.stringify(data), id:form_id}, function(data){
                    //echo"success"
            });

        return false;       
    });
/*-----------------------END_FORM_SUBMISSION------------------------*/


/*---------------fetch_record-------------*/    
    $.getJSON('form_editor.php', {data:'data'},  function(data){
        $.each(data, function(key, val){
            var n = key;
            console.log(n)
        });
    });

});
</code></pre>
