2015-05-29 57 views
1

https://www.dropbox.com/s/e89hjxrogghll9a/1.jpg?dl=0 https://www.dropbox.com/s/sjqfsuwj9mlpc2o/2.jpg?dl=0 請參閱上面的圖像鏈接。圖像顯示的過程獲取正確的ID值並填充到模態彈出框

如果我點擊我選擇的表,它不能選擇正確的數據。這是我的代碼。謝謝你的幫助

<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 
 
} 
 

 

 
?>

回答

0

您需要更換各模態元素的#proceed ID和H ref元素,使它們對應

對於你的表

<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函數來加載所述表單。但那只是我,這就是另一個話題。

但是這應該解決您的問題。

+0

先生,它的工作感謝幫助:) –