1

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?

asked Aug 19, 2010 at 7:10
1
  • 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? Commented Aug 19, 2010 at 7:14

2 Answers 2

6

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.

Justin Johnson
31.3k7 gold badges67 silver badges89 bronze badges
answered Aug 19, 2010 at 7:17
Sign up to request clarification or add additional context in comments.

Comments

0

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.

answered Aug 19, 2010 at 7:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.