How to get another user's details using RestFB?

How can I pass a multidimensional array using PHP from an HTML form to a MySQL database?

  • I am currently trying to build a web form here: http://gillianthonydance.com/dancealparty2012/index_2.php The radio buttons are in three sections as there are three users. I have managed to get the form working passing a single user's details to the mysql database but I cannot get my head around how to pass the $_POST multi-dimensional array to the Mysql Insert statement. I know the data is being passed to the processing page as I can generate a response using "echo $_POST". I have hunted the web but for the life of me cannot find an easy tutorial to walk me through this process.    Can anyone recommend a good and thorough tutorial on this subject with clear coding examples?

  • Answer:

    You can actually access whats inside your post variable. Example: If you have an input with the name="foobar" - then you can access that through $_POST['foobar'] To view the whole contents of your post variable, use the print_r() function Like this: <?php //Displays keys and their values of $_POST nicely echo '<pre>'; print_r($_POST); echo '</pre>'; ?> So solve the problem with storing data from a multidimensional array, you can either choose to store them individually if the structure and keys are fixed. If that's not the case, then you can serialize() the array, and store it that way. Then of course unserialize() when you fetch it again.

Dennis Micky Jensen at Quora Visit the source

Was this solution helpful to you?

Other answers

Hi, You can iterate through the multi dimensional array and insert data into the DB on each iteration. Please do a <?php dump($_POST); //use the function below. function dump($array){ echo '<pre>'; print_r(json_encode($array)); echo '</pre>'; } ?> Please post the json here, so that i can post asmall code smaple to iterate through the array. note: you can do a dump of the array itself, but i am too lazy to manually construc the array :), so Json would help! cheers, rajesh

Eswar Rajesh Pinapala

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.