将表PHP中的变量传递给引导模式

时间:2018-09-24 08:21:19

标签: php

我只是想知道如何在php的模态中传递变量,我需要显示一个模态,其中用户可以编辑所选行,但是在将所选行的变量传递给php时遇到了麻烦模态 这是我的代码:

urlArray

这是模态

let URL1 = "www.site.com/something/car/123"
let URL2 = "www.site.com/something/somethingelse/banana/"

let urlArray = ['/car/','/boat/','/apple/','/banana/'];

let index1 = urlArray.findIndex(str => URL1.includes(str))
let index2 = urlArray.findIndex(str => URL2.includes(str))

console.log(index1, index2)

仅当我单击最后一个记录时,才会显示模式。

1 个答案:

答案 0 :(得分:0)

我认为您的模式html代码不在while语句中。

我不确定,但是您可以尝试如下操作。

<?php
$query = mysqli_query($conn,"SELECT * FROM techsupport,techdetails WHERE techsupport.id = techdetails.id");

while ($fetch=mysqli_fetch_array($query)) {

$ids = $fetch['id'];
$serv_code = $fetch['service_code'];
?>
<tr>
<td><a href='#' data-target='#editModal<?php echo $ids;?>' data-toggle='modal' ><i class='fa fa-edit'></i></a></td>
<td><?php echo $fetch['id'];?></td>
<td><?php echo $fetch['service_code'];?></td>
<td><?php echo $fetch['log_date'];?></td>
<td><?php echo $fetch['title'];?></td>
<td><?php echo $fetch['remarks'];?></td>
<td><?php echo $fetch['status'];?></td>
<td><?php echo $fetch['parts'];?></td>
<td><?php echo $fetch['request_date'];?></td>
<td><?php echo $fetch['received_date'];?>
    <!-- Hidden Modal -->
      <div class="modal fade" id="editModal<?php echo $ids;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
         <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
           <button type="button" class="close" data-dismiss="modal" aria-label="Close">
           <span aria-hidden="true">&times;</span>
           </button>
        </div>
        <div class="modal-body">
         ...
        </div>
        <div class="modal-footer">
           <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
           <button type="button" class="btn btn-primary">Save changes</button>
        </div>
       </div>
       </div>
      </div>
    <!--Ends Hidden Modal -->
 </td>
 </tr>
<?php } ?>


        </table>
    </div>
</div>