wordpress update records from dynamic fields

I have a system in which new text fields are added dynamically in which new values can be entered . i want to update those values into database but since the values are dyanmic how can i get them and store them with php form submit ?

Html example

Read More
            <tbody>
                <tr valign="top">
                    <th scope="row"><label for="user_limit_for_role">s2member level1</label></th>
                    <td><input type="text" id="" name="s2member_level1" value="400"></td>
                </tr>


                <tr valign="top">
                    <th scope="row"><label for="user_limit_for_role">s2member level2</label></th>
                    <td><input type="text" id="" name="s2member_level2" value="400"></td>
                </tr>


                <tr valign="top">
                    <th scope="row"><label for="user_limit_for_role">administrator</label></th>
                    <td><input type="text" id="" name="administrator" value="500"></td>
                </tr>


            </tbody>

in above html the name of the fields such as s2members_level1 and its value already exist in database and it coming there , but if user changes the value i need those to be updated and since a new member level record can be added on the spot dynamically increasing the row how can i update these values ?

for a single value i can use

$status = $wpdb->query("UPDATE wp_arete_bp_limit_settings SET limit_allowed='500' WHERE membership_role = 's2member_level1'");

But how to get values from dynamic input fields and store them accordingly .

Related posts

Leave a Reply

1 comment

  1.            <tbody>
                <tr valign="top">
                    <th scope="row"><label for="user_limit_for_role">s2member level1</label></th>
                    <td><input type="text" id="" name="s2member_level[]" value="400"></td>
                </tr>
    
    
                <tr valign="top">
                    <th scope="row"><label for="user_limit_for_role">s2member level2</label></th>
                    <td><input type="text" id="" name="s2member_level[]" value="400"></td>
                </tr>
    
    
                <tr valign="top">
                    <th scope="row"><label for="user_limit_for_role">administrator</label></th>
                    <td><input type="text" id="" name="administrator" value="500"></td>
                </tr>
    
    
            </tbody>
    

    Now,
    in your php,
    you can loop through each s2member_level with

    $arr = $_GET['s2member_level'];
    foreach($arr as $s2member_level'])
    {
       ... //do your job
    }