gpt4 book ai didi

php - 在模态视图上显示所选行的完整信息

转载 作者:行者123 更新时间:2023-11-29 21:10:21 25 4
gpt4 key购买 nike

示例:

我每行有 6 列。

    Column1 = personid
Column2 = Image
Column3 = FirstName
Column4 = MiddleName
Column5 = LastName
Column6 = Position

示例:

Person ID  Image          FirstName    MiddleName   LastName   Position
1 Picture1.jpg John Doe Peter Manager

PHP 代码是:

<?php
include('connect.php');
$selected=mysql_query("SELECT * FROM persontbl order by personid");
$i=1;
while($personrow=mysql_fetch_array($selected))

{
$personid=$personrow['personid'];
$personimage=$personrow['personimage'];
$firstname=$personrow['firstname'];
$middlename=$personrow['middlename'];
$lastname=$personrow['lastname'];
$position=$personrow['position'];

?>

我创建了此代码来使用 bootstrap(仅图像和名字)在 GridView 上显示行的特定信息:

<div class="col-sm-2">
<a href="" data-toggle="modal" data-target="#myModal" class="thumbnail home-thumb"><img src="<?php echo $personimage;?>" alt=""></a>
<p><h5 align="center"><?php echo $FirstName; ?></h5></p>
<hr/>
</div>

模态形式为:

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn btn-info close" data-dismiss="modal">Close Form &times;</button>
<h4 class="modal-title">Full Information of the Person</h4>
</div>
<div class="modal-body">
<p><img src="<?php echo $personimage; ?>" width="25%" height="25%" alt="">
<h5><b> Person's Name: </b></h5><?php echo $FirstName; ?></p>
<hr/>
<p><h5><b>Person's Middle Name: </b></h5><?php echo $middlename; ?></p>
<p><h5><b>Person's Last Name: </b></h5><?php echo $lastname; ?></p>
<p><h5><b>Person's Position: </b></h5><?php echo $position; ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close Form</button>
</div>
</div>

然后我想在模态视图上显示完整的信息。然后,当我单击一个记录行时,将弹出模态视图并显示所选记录行的完整信息。

但是现在,模态框仅显示第一行的信息。当我单击另一行时,它不会显示所选行的完整信息,它只显示第一行的数据。但它仍然打开模态框。

如何使用 PDO 方法将所选记录的完整信息从数据库显示到模态视图?请提供完整的代码详细信息来支持我。

最佳答案

这是我在本地主机中测试的代码

<?php
include('login/dbconnect.php');
$selected=mysqli_query($conn,"SELECT * FROM leads");
$i=1;
?>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>


<?php

while($personrow=mysqli_fetch_array($selected))

{
$personid=$personrow['ID'];
$FirstName=$personrow['FIRST_NAME'];

?>
<div class="col-sm-2">
<a href="" data-toggle="modal" data-target="#<?php echo $personid ?>" class="thumbnail home-thumb"><img src="<?php echo $personimage;?>" alt=""></a>
<p><h5 align="center"><?php echo $FirstName; ?></h5></p>
<hr/>
</div>

<div id="<?php echo $personid ?>" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn btn-info close" data-dismiss="modal">Close Form &times;</button>
<h4 class="modal-title">Full Information of the Person</h4>
</div>
<div class="modal-body">

<p>hiiiiiiiiiiiiiiii</p>
<p><?php echo $FirstName; ?></p>
<!-- <h5><b> Person's Name: </b></h5><?php echo $FirstName; ?></p>
<hr/>
<p><h5><b>Person's Middle Name: </b></h5><?php echo $middlename; ?></p>
<p><h5><b>Person's Last Name: </b></h5><?php echo $lastname; ?></p>
<p><h5><b>Person's Position: </b></h5><?php echo $position; ?></p> -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close Form</button>
</div>
</div>
</div>
</div>

<?php
}

?>

关于php - 在模态视图上显示所选行的完整信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36427433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com