获取ID的正确值并填充到模式弹出菜单


Getting Correct value of ID and Populate to Modal Popup

https://www.dropbox.com/s/e89hjxrogghll9a/1.jpg?dl=0https://www.dropbox.com/s/sjqfsuwj9mlpc2o/2.jpg?dl=0有关图片,请参阅上面的链接。图像显示了的过程

如果我单击所选的表,它将无法选择正确的数据。这是我的密码。感谢的帮助

 <table id="example2" class="table table-bordered table-hover">
                    <thead>
                      <tr>
                        <th>Code</th>
                        <th>Date of Request</th>
                        <th>Requestor Name</th>
                        <th>Form Type</th>
                        <th>Request Type</th>
                         <th>Details</th>
                         <th>Date Needed</th>
                         
                        <th>Action</th>
                         
                      </tr>
                    </thead>
             
                <?php
             
                    $req1 = mysql_query('select * from mainviewrequestor where username="'.$_SESSION['username'].'"  and req_dateapprove IS NULL');
while($dn1 = mysql_fetch_array($req1))
{
?>
<tr>
       <td><?php echo date($dn1['req_code']); ?></td>  
       <td><?php echo date($dn1['req_date']); ?></td>
      <td class="left"><a href="read_pm.php?id=<?php echo $dn1['id']; ?>"><?php echo htmlentities($dn1['empname'], ENT_QUOTES, 'UTF-8'); ?></a></td>
      
      <td><?php echo htmlentities($dn1['form_name'], ENT_QUOTES, 'UTF-8'); ?></td>
      <td> <?php echo $dn1['itrf_type']?></td>
      <td> <?php echo $dn1['itrf_details']?></td>
      <td> <?php echo $dn1['req_dateneeded']?></td>
       <td class="left"><a href="#proceed" data-toggle="modal"><button type="submit" class="btn btn-primary" name="approved">View</button></a>
        <button type="submit" class="btn btn-primary" name="btn-sub2">DisApproved</button></td>
      
    </tr>
   
     
    <?php
}
if(intval(mysql_num_rows($req1))==0)
{
?>
  <tr>
      <td colspan="4" class="center">You have no unread message.</td>
    </tr>
<?php
}
?>
</table>
<br />
<?php
}
?>
           
                     
                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
                   
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
     <?php
       
     
                     
                $req1 = mysql_query('select * from mainviewrequestor2');
while($dn1 = mysql_fetch_array($req1))                        
{
                 ?>
<!--Pop-up modal Code-->
<div class = "modal fade" id="proceed" role="dialog">
  <div class = "modal-dialog modal-lg">
       <div class = "modal-content">
          <div class = "modal-header">
              <h4>REQUEST TABLES</h4>
                <h2>------------------------------------------------------------------------------------------</h2>
               
                 
              <div class="content">  
                <form>  
                   <label>Date Created: </label><input type="text" name="req_date" id="req_date" value="<?php echo ($dn1['req_date']); ?>" /><br />
                   <label>Request By: </label><input type="text" name="empname" id="empname" value="<?php echo ($dn1['empname']) ?>" /><br />
                   <label>Form Name: </label><input type="text" name="form_name" id="form_name" value="<?php echo $dn1['form_name']?>" /><br />
                   <label>Request Type: </label><input type="text" name="itrf_type" id="itrf_type" value="<?php echo $dn1['itrf_type']?>" /><br />
                   <label>Details: </label><input type="text" name="itrf_details" id="itrf_details" value="<?php echo $dn1['itrf_details']?>" /><br />
                    <label> Date Needed:</label><input type="text" name="req_dateneeded" id="req_dateneeded" value="<?php echo $dn1['req_dateneeded']?>" /><br />
                  
                  <button type="submit" class="btn btn-primary" name="req_code">Approved</button>
                  <button type="submit" class="btn btn-primary" name="update2">Disapproved</button>
                 
                 </form> 
                </div>
 <?php
}
?>

您需要替换每个模态元素和h-ref元素上的#proceed id,以便它们对应

对于您的桌子

<a href="#proceed-<?php echo $req1['id'];?>" data-toggle="modal">

对于您的模式

while($dn1 = mysql_fetch_array($req1))                        
{?>
<div class = "modal fade" id="proceed-<?php echo $dn1['id'];?>" role="dialog">

尽管这是一种相当丑陋的做事方式。相反,我只创建一个模态,并将ID传递给ajax函数来加载所述表单。但这只是我自己,这是另一个主题。

但这应该能解决你的问题。