I have been scratching my head about this for days and i cant seem to understand why this isnt working,
i have a modal which pops up when selecting the accept button, this modal should populate the users name and telephone number.
the problem is that when you select the accept it only populate the first persons details and no the rest of the people in the table, i dont understand why if anyone can point out why i would be much obliged
here is my code (sorry its abit messy at the moment):
<?php
require_once ("includes/session_check.php");
require_once ("includes/db_connect.php");
//MySqli Select Query
$results = $mysqli->query("SELECT id, username, phone, requester,goodorbad,confirmed,denied FROM request WHERE goodorbad=1 AND confirmed=0 AND denied=0 Order by ID ASC");
echo '
<!-- **********************************************************************************************************************************************************
MAIN CONTENT
*********************************************************************************************************************************************************** -->
<!--main content start-->
<section id="main-content">
<section class="wrapper site-min-height">
<h3><i class="fa fa-angle-right"></i> Non Authenticated Requests</h3>
<div class="row mt">
<div class="col-lg-12">
<p>Non Authenticated Requests here.</p>';
echo '<div class="row mt">
<div class="col-md-12">
<div class="content-panel">
<table class="table table-striped table-advance table-hover">
<h4><i class="fa fa-angle-right"></i>Non Authenticated Requests</h4>
<hr> <thead>
<tr>
<th><i class="fa fa-bullhorn"></i>Username</th>
<th><i class="fa fa-phone"></i>Phone number update request</th>
<th><i class="fa fa-bookmark"></i>Requester</th>
<th><i class=" fa fa-edit"></i> Status</th>
<th><i class=" fa fa-edit"></i> Accept/Decline</th>
<th></th>
</tr>
</thead>';
while($row = $results->fetch_object()) {
//$row->id
//$row->confirmed
//$row->denied
$status = $row->confirmed;
echo '
<!-- Modal for Confirm -->
<form action="#" method="POST">
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<input type="hidden" name="username_request" value="'.$row->username.'"/>
<input type="hidden" name="telephone_request" value="'.$row->phone.'"/>
<h4 class="modal-title">Are you sure ?</h4>
</div>
<div class="modal-body">
<br>
<p>You are about to update </p>
'.$row->username.'
<br>
<p> with the following telephone number </p>
'.$row->phone.'
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default"
type="button">Cancel</button>
<button data-dismiss="modal" class="btn btn-default"
type="button">Submit</button>
</div>
</div>
</div>
</div>
</form>
<!-- modal -->
<tbody>
<tr>
<td><a href="#">'.$row->username.'</a></td>
<td>'.$row->phone.'</td>
<td>'.$row->requester.' </td>';
if($status == 1){
echo ' <td><span class="label label-success">Completed</span></td>
<td></td>
<td></td>
';
}else{
}
echo '<td><span class="label label-info label-mini">Pending</span></td>
<td>
Accept?
<a data-toggle="modal" href="#myModal"> <button class="btn btn-success btn-xs"><i class="fa fa-check"></i></button>
</a>
<td>
Decline?
<button class="btn btn-danger btn-xs"><i class="fa fa-minus-circle"></i></button>
</td>
</td>
</tr>
</tbody>
';
}
echo '
</table>
</div><!-- /content-panel -->
</div><!-- /col-md-12 -->
</div><!-- /row -->';
// close connection
$mysqli->close();
?>
<html>
</html>
You need to add unique id
to every model
.
Try
<?php
require_once ("includes/session_check.php");
require_once ("includes/db_connect.php");
//MySqli Select Query
$results = $mysqli->query("SELECT id, username, phone, requester,goodorbad,confirmed,denied FROM request WHERE goodorbad=1 AND confirmed=0 AND denied=0 Order by ID ASC");
echo '
<!-- **********************************************************************************************************************************************************
MAIN CONTENT
*********************************************************************************************************************************************************** -->
<!--main content start-->
<section id="main-content">
<section class="wrapper site-min-height">
<h3><i class="fa fa-angle-right"></i> Non Authenticated Requests</h3>
<div class="row mt">
<div class="col-lg-12">
<p>Non Authenticated Requests here.</p>';
echo '<div class="row mt">
<div class="col-md-12">
<div class="content-panel">
<table class="table table-striped table-advance table-hover">
<h4><i class="fa fa-angle-right"></i>Non Authenticated Requests</h4>
<hr> <thead>
<tr>
<th><i class="fa fa-bullhorn"></i>Username</th>
<th><i class="fa fa-phone"></i>Phone number update request</th>
<th><i class="fa fa-bookmark"></i>Requester</th>
<th><i class=" fa fa-edit"></i> Status</th>
<th><i class=" fa fa-edit"></i> Accept/Decline</th>
<th></th>
</tr>
</thead>';
$i = 1;
while($row = $results->fetch_object())
{
//$row->id
//$row->confirmed
//$row->denied
$status = $row->confirmed;
echo '
<!-- Modal for Confirm -->
<form action="#" method="POST">
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal'.$i.'" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<input type="hidden" name="username_request" value="'.$row->username.'"/>
<input type="hidden" name="telephone_request" value="'.$row->phone.'"/>
<h4 class="modal-title">Are you sure ?</h4>
</div>
<div class="modal-body">
<br>
<p>You are about to update </p>
'.$row->username.'
<br>
<p> with the following telephone number </p>
'.$row->phone.'
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default"
type="button">Cancel</button>
<button data-dismiss="modal" class="btn btn-default"
type="button">Submit</button>
</div>
</div>
</div>
</div>
</form>
<!-- modal -->
<tbody>
<tr>
<td><a href="#">'.$row->username.'</a></td>
<td>'.$row->phone.'</td>
<td>'.$row->requester.' </td>';
if($status == 1)
{
echo ' <td><span class="label label-success">Completed</span></td>
<td></td>
<td></td>
';
}
echo '<td><span class="label label-info label-mini">Pending</span></td>
<td>
Accept?
<a data-toggle="modal" href="#myModal'.$i.'"> <button class="btn btn-success btn-xs"><i class="fa fa-check"></i></button>
</a>
<td>
Decline?
<button class="btn btn-danger btn-xs"><i class="fa fa-minus-circle"></i></button>
</td>
</td>
</tr>
</tbody>
';
$i++;
}
echo '
</table>
</div><!-- /content-panel -->
</div><!-- /col-md-12 -->
</div><!-- /row -->';
// close connection
$mysqli->close();
?>
<html>
</html>