editing with AJAX and PHP\mysql
<p>with plenty of visits i found helpful answers from all of you and hope this also give me some idea about my problem.</p>

<p>Basically i'm trying to edit mysql data with ajax. i have done with following code.</p>

<p><strong>Step 1-   i loaded data from server with following script</strong></p>

<pre><code>$("#editselected,#addselected").live("click", function(){
   var whatto=$(this).attr('id');var edit_ids = new Array();
   $(".selectable:checked").each(function() {
   edit_ids.push($(this).attr('name'));
    });
   $("#editadd").load("ajaxloads/addedit.php?idarray="+edit_ids+"&amp;action="+whatto,Hide_Load());
   //centerPopup();//loadPopup();
     }); 
</code></pre>

<p><strong>AND ITs Server DATA is</strong></p>

<pre><code>if($selectall_action=='editselected'){   ?&gt;
    &lt;table id="main" class="editallmainwidth"&gt;
    &lt;thead&gt;
    &lt;tr&gt;
    &lt;th scope="col" &gt;Vendor&lt;/th&gt;
    &lt;th scope="col" &gt;ItemType&lt;/th&gt;
    &lt;th scope="col" &gt;ItemCode&lt;/th&gt;
    &lt;th scope="col" &gt;ItemName&lt;/th&gt;
    &lt;th scope="col" &gt;SerialNo&lt;/th&gt;
    &lt;th scope="col" &gt;AssetCode&lt;/th&gt;
    &lt;th scope="col" &gt;Ownership&lt;/th&gt;
    &lt;th scope="col" &gt;PO&lt;/th&gt;
    &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
    &lt;?php
   $ids= split(",",$selectall_id_array);
foreach($ids as $sid)
{

$stock=mysql_query("select * FROM $region where id='$sid'");

            while($q=mysql_fetch_array($stock))
            {
    echo "&lt;tr&gt;";      

    echo "&lt;td width=\"5%\"&gt;&lt;input type='hidden' name='id_all' value='{$q[8]}' /&gt;&lt;input type='text'  name='vend_all' value='$q[0]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"5%\"&gt;&lt;input type='text' name='type_all' value='$q[1]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"8%\"&gt;&lt;input type='text' name='code_all' value='$q[2]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"20%\"&gt;&lt;input type='text' name='desc_all' value='$q[3]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"10%\"&gt;&lt;input type='text' name='seno_all' value='$q[4]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"5%\"&gt;&lt;input type='text' name='acode_all' value='$q[5]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"2%\"&gt;&lt;input type='text' name='os_all' value='$q[9]' /&gt;&lt;/td&gt;";
    echo "&lt;td width=\"5%\"&gt;&lt;input type='text' name='porder_all' value='$q[12]' /&gt;  &lt;/td&gt;";

    echo "&lt;/tr&gt;";
            }

     }  
     ?&gt;
      &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;fieldset id="add"&gt;
            &lt;input type="submit" id='editall' name="Modify" value="EditAll" /&gt;   &lt;/fieldset&gt;
</code></pre>

<p>

<p><strong>Step-2 Then I edited The loaded text boxes filled with server data and send back ajax request to server</strong></p>

<pre><code>$("#editall").live("click", function(){

    var id_alledit = new Array();
    var vendor_alledit = new Array();
    var type_alledit = new Array();
    var code_alledit = new Array();
    var desc_alledit = new Array();
    var seno_alledit = new Array();
    var acode_alledit = new Array();
    var os_alledit = new Array();
    var po_alledit = new Array();

    var isedited=$("#editall").val();



$("input[name='id_all']").map(function(index) {
id_alledit.push($(this).attr('value'));
});

var tcount=$("input[name='id_all']").length;

 $("input[name='vend_all']").map(function(index) {
vendor_alledit.push($(this).attr('value'));
 });


 $("input[name='type_all']").map(function(index) {
 type_alledit.push($(this).attr('value'));
 });

 $("input[name='code_all']").map(function(index) {
code_alledit.push($(this).attr('value'));
});

 $("input[name='desc_all']").map(function(index) {
 desc_alledit.push($(this).attr('value'));
 });

 $("input[name='seno_all']").map(function(index) {
 seno_alledit.push($(this).attr('value'));
});

$("input[name='acode_all']").map(function(index) {
acode_alledit.push($(this).attr('value'));
});
$("input[name='os_all']").map(function(index) {
os_alledit.push($(this).attr('value'));
});
 $("input[name='porder_all']").map(function(index) {
po_alledit.push($(this).attr('value'));
});



jQuery.ajax({
type:"POST",url:"ajaxloads/addedit.php",
data:"&amp;id_arrays=" + id_alledit + "&amp;vend_arrays=" + vendor_alledit + "&amp;type_arrays=" +         type_alledit + "&amp;code_arrays=" + code_alledit + "&amp;desc_arrays=" + desc_alledit +   "&amp;seno_arrays=" + seno_alledit + "&amp;os_arrays=" + os_alledit + "&amp;acode_arrays=" +   acode_alledit + "&amp;po_arrays=" + po_alledit + "&amp;ifedited=" + isedited + "&amp;tcount=" + tcount  ,
      complete:function(data){


 //$("#main").load("ajaxloads/addedit.php",null,function(responseText){ 
 //$("#main").html(responseText);
//$('tr:even',this).addClass("odd");
   alert(data.responseText);
 //}); 

   }
 }); 

  //disablePopup(); 
   return false;
  });
</code></pre>

<p><strong>AND Updation was done with the following server side code</strong></p>

<pre><code>if(isset($_POST[ifedited])=='EditAll')

{

$id_count= $_POST[tcount];
$idarray=split(",",$_POST[id_arrays]);
$vendarray=split(",",$_POST[vend_arrays]);
$typearray=split(",",$_POST[type_arrays]);
$codearray=split(",",$_POST[code_arrays]);
$descarray=split(",",$_POST[desc_arrays]);
$senoarray=split(",",$_POST[seno_arrays]);
$acodearray=split(",",$_POST[acode_arrays]);
$osarray=split(",",$_POST[os_arrays]);
$poarray=split(",",$_POST[po_arrays]);
//print_r($idarray);

       for($i=0;$i&lt;=$id_count;$i++)
 {
 //echo $id_count;
 echo $idarray[$i];
 echo $typearray[$i];
 echo $vendarray[$i];
 echo $codearray[$i];
 echo $descarray[$i];
 echo $senoarray[$i];
 echo $acodearray[$i];
 echo $osarray[$i];
 echo $poarray[$i];

 mysql_query("update Query");



 }

    }
</code></pre>

<p>*Every thing working fine but it seems like steps for this are being used are 
quite lengthy and may cause a performance issue.
i Need if some can suggest me a better way of doing all this. Or if <strong>JSON</strong> is better option? and if it is then how i can Creat A JSON with associative arrays.</p>

<p>Thanks*        </p>
