I'm working with two forms on the same page. both have the same select where the admin can select a user. for that, I'm using find_all()
function I've created. which Select everything from the given table name. then I'm using while loop
to populate select options. they are displaying on the first form correctly. but the second form is empty. I want to know why this is happening. any idea? thank you :)
<?php $users = find_all('ph_users'); ?>
// first form
<form action="credits_manage.php" method="post">
<div class="form-group">
<label for="credits_amount">Credits Amount</label>
<input type="number" placeholder="Enter credits amount" id="credits_amount" class="form-control" required>
</div>
<div class="form-group">
<label for="user">Select User</label>
<select name="user" id="user" class="form-control" required>
<option value="">Select...</option>
<?php while ($user = mysqli_fetch_assoc($users)) { ?>
<option value="<?php echo $user['user_id']; ?>"><?php echo $user['username']; ?></option>
<?php } ?>
</select>
</div>
<input type="submit" value="Give Credits" name="give-credits-submit" class="btn btn-primary waves-effect waves-light mt-2">
</form>
// second form
<form action="">
<div class="form-group">
<label for="credits_amount">Credits Amount</label>
<input class="form-control" type="password" value="lachiweb" id="credits_amount" required>
</div>
<div class="form-group">
<label for="remove_credits_user">Select User</label>
<select name="remove_credits_user" id="remove_credits_user" class="form-control" required>
<option value="">Select...</option>
<?php while ($remove_credits_user = mysqli_fetch_assoc($users)) { ?>
<option value="<?php echo $remove_credits_user['user_id']; ?>"><?php echo $remove_credits_user['username']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<label for="reason">Choose a Reason</label>
<input class="form-control" type="password" value="lachiweb" id="reason" required>
</div>
<input type="submit" value="Remove Credits" name="update-password-submit" class="btn btn-primary waves-effect waves-light mt-2">
</form>