Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i need to push data in javascript array into database using PHP

first i have multidimentional array in js.

Brady [0] [0] = "1";
Brady [0] [1] = "Carol";
Brady [1] [0] = "2";
Brady [1] [1] = "Jan";
Brady [2] [0] = "3";
Brady [2] [1] = "Mike";

and i have table in database such as (id, name)

second if i need to delete some rows in array before i added how can i do?

third how can i push it to database after i delete data in array?

share|improve this question
    
Have you got anything already or do you simply have no idea where to start? Do you know enough PHP/SQL to put something into a database? –  deceze Aug 19 '10 at 7:14

2 Answers 2

up vote 0 down vote accepted

You must know the basics of AJAX concept. Parameter passing of its your own interest either

  1. separate items

    ex: xmlHttpReq.open('GET', "/test.json&day=" + day + "&month=" + month + "&year=" + year, true);

  2. concat array as a string with special character and send ,parse it at backend

    ex:

    string sample=array[0]+'|'+array1....

       xmlHttpReq.open('GET', "/test.json&arrtest=" +sample , true);
    

    at backend use explode string to make it as array again.

share|improve this answer

Pass it to PHP as a JSON-encoded string, let PHP reconstruct it as a PHP array using json_decode(), and then just treat it like a normal PHP array.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.