I need to update the "display_name" in the database, for that I display all of the users using a wordpress function and a foreach, and add next to each user a textbox(to change the name) and a button (to perform the action), my question is how can I get the correct ID for the input and button that I am clicking, if Im looping the users?
<?php global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM $wpdb->users" );
?>
<form>
<?php
foreach ($results as $key ) {
echo "$key->ID . $key->display_name <input type='text' name=''> <button>Submit</button>
}
?>
</form>
Im currently trapped in this, i get the id but the value of the first textbox
<?php
global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM $wpdb->users" );
?><form id="form1"><?php
foreach ($results as $key ) {
echo "$key->ID . $key->display_name . $key->mg_nobility <input type='text'
id='edit_value' class='$key->ID' value=''> <button row_id='$key-
>ID'class='edit_nov'>Submit</button>";
}
?>
</form>
<input type='hidden' id='row_del_id' value=''>
<input type='hidden' id='row_up_id' value=''>
<script>
jQuery('.edit_nov').click(function()
{
var current_id = jQuery(this).attr('row_id');
var current_value =jQuery('#edit_value').val();
jQuery('#row_del_id').val(current_id);
jQuery('#row_up_id').val(current_value);
return false;
});
</script>