Viewed   71 times

I want to know how i can post a multi-dimensional array?

Basically i want to select a user and selected user will have email and name to sent to post.

So selecting 100 users, will have email and name. I want to get in PHP like following

$_POST['users'] = array(
  array(name, email),
  array(name2, email2),
  array(name3, email3)

Any ideas?



You can name your form elements like this:

<input name="users[1][name]" />
<input name="users[1][email]" />
<input name="users[2][name]" />
<input name="users[2][email]" />

You get the idea...

Sunday, September 18, 2022

Instead of sorting the table in PHP, you may consider doing it client-side in Javascript. For instance have a look at this jQuery plugin:

Tuesday, September 13, 2022

In jQuery documenation here:
Only succesful control are serialized, please see the documentation below:

Note: Only "successful controls" are serialized to the string. No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute. Values from checkboxes and radio buttons (inputs of type "radio" or "checkbox") are included only if they are checked. Data from file select elements is not serialized.

So submit buttn won't serialize through jQuery.serialize() function. The work around is you can add hidden input, and it will serialized.

You need to change the form submit ajax to bind the button click. and in ajax request you can add the button value manually. Below is my code that is working.

$( "#delImage" ).click(function( event ) {
    $form = $(this).parent('form');
    $btnid = $(this).attr('name');
    $btnval = $(this).attr('value');

        url: $form.attr('action'),
        type: $form.attr('method'),
        data: { "btnid" : $btnid, "btnval": $btnval, "form-data": $form.serialize() },
        success: function(html) {
Saturday, August 20, 2022

This should be something like this:

function rec($arr, $prefix ="") {
    if ($prefix != "") $prefix .= "/";
    foreach($arr as $e) {
        echo $prefix . $e['name'];
        if (!empty($e['children']))
            rec($e['children'], $prefix . $e['name']);

I not on computer so this pseudo code only...

Saturday, November 12, 2022

I believe you're looking for the success in the .ajax options parameter.

  success: function(d){
Wednesday, September 21, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :