php - Loop of outputted data only allowing changes to be made to the first record -
i have page made can accept/deny user. once user has been accepted, change group of membership grant permission levels , allow them login. reason though, if try change anyone's group level not firs outputted user loop, changes first person's data.
so if had list this...
-mike
-bob
-suzy
if tried change bob's group, changes mike's.
why be?
here code in seeing can't see.
$con2 = mysqli_connect("localhost", "", "", ""); $run2 = mysqli_query($con2,"select * user_requests order id desc"); $runusers2 = mysqli_query($con2,"select * users order id desc"); $numrows2 = mysqli_num_rows($run2); if( $numrows2 ) { while($row2 = mysqli_fetch_assoc($run2)){ if($row2['status'] == "approved"){ //var_dump ($row2); $approved_id = $row2['user_id']; $approved_firstname = $row2['firstname']; $approved_lastname = $row2['lastname']; $approved_username = $row2['username']; $approved_email = $row2['email']; if ($approved_firstname == true) { echo "name - ". $approved_firstname . " " . $approved_lastname . "</br>" . "username - ". $approved_username . "</br></br>" ?> <div class="change_group_button"> <a class="change_group" href="javascript:void(0)">change user permission</a> </div><br> <div id="light" class="change_group_popup"> <a class="close" href="javascript:void(0)">close</a> <div class="group_success" style="color: red;"></div><br> <form id="update_group" action="" method="post" accept-charset="utf-8"> <div class="field"> <label for="group">group</label> <input type="hidden" value="<?php echo $approved_id; ?>" id="approved_id" name="id" /> <input type="hidden" value="<?php echo $approved_firstname; ?>" id="approved_firstname" name="firstname" /> <input type="hidden" value="<?php echo $approved_lastname; ?>" id="approved_lastname" name="lastname" /> <input type="hidden" value="<?php echo $approved_username; ?>" id="approved_username" name="username" /> <input type="hidden" value="<?php echo $approved_email; ?>" id="approved_email" name="email" /> <select id='group_id' name='group' required> <option value=''><?php echo htmlentities($group); ?></option> <option value="1">bench</option> <option value="2">spectator</option> <option value="3">team member</option> <option value="4">commissioner</option> <option value="6">deny</option> </select> </div> <input type="submit" value="submit" name="group"> </form>
ajax call
$(document).ready(function () { $('#update_group').on('submit', function (event) { event.preventdefault(); $.ajax({ url: 'user_group_update.php', type: 'post', data: { id: $("#approved_id").val(), //id firstname: $("#approved_firstname").val(), //firstname lastname: $("#approved_lastname").val(), //lastname username: $("#approved_username").val(), //username email: $("#approved_email").val(), //email // update_group: $("#group_id").val() //group level update_group: $(this).find( "#group_id option:selected" ).val() }, success: function (data) { //do data got returned $(".group_success").fadein(); $(".group_success").show(); $('.group_success').html('user permission level changed!'); $('.group_success').delay(5000).fadeout(400); //alert(data); }, error: function(jqxhr, textstatus,errorthrown ) { // alert on http error alert( textstatus + errorthrown ); } }); return false; }); });
Comments
Post a Comment