用模态揭示的mysql数据的mutbel php

时间:2017-04-27 09:17:48

标签: javascript php jquery html css

我希望在一个页面中使用模态显示

将链接#与id一起转换为div id
<a href="#?id=<?php echo $id; ?>" class="team-detail" data-reveal-id="single-news"></a>

<!-- Pop Up Windows - Single Blog Post -->
<div id="single-news" class="reveal-modal single-news small" data-reveal>

<?php
     $member = mysql_query("SELECT*FROM team WHERE id = '$_GET[id]'");
     $m = mysql_fetch_array($member);
?>  
<div class="twelve columns first-column">
    <p class="single-news-content"><?php echo $m[quote]; ?></p>
</div>
    <a class="close-reveal-modal">&#215;</a>
</div>

但$ _GET不起作用,查询无法正常工作

2 个答案:

答案 0 :(得分:0)

我想你想在模型弹出中传递$id参数:

尝试使用以下代码:

<a class="btn btn-primary btn-xs" data-toggle="modal" data-target="#editBox" href="file.php?id=<?php echo $id;?>">

现在创建一个PHP文件并将其命名为file.php

使用模态调用按钮href="file.php?id=<?php echo $id;?"

调用此文件
<?php
//Include database connection here
$Id = $_GET["id"]; //escape the string if you like
// Run the Query
?>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title"><center>Heading</center></h4>
</div>
<?php
     $member = mysql_query("SELECT*FROM team WHERE id = '$_GET[id]'");
     $m = mysql_fetch_array($member);
?>  
<div class="modal-body">
     <p class="single-news-content"><?php echo $m[quote]; ?></p>
</div>
<a class="close-reveal-modal">&#215;</a>
</div>

<script>
$( document ).ready(function() {
    $('#editBox').on('hidden.bs.modal', function () {
          $(this).removeData('bs.modal');
    });
});
</script>

您可以看到完整的流程here

希望这有帮助!!!

答案 1 :(得分:0)

<a href="filename.php?id=<?php echo $id; ?>" class="team-detail" data-reveal-id="single-news"></a>

通过你的

    <!-- Pop Up Windows - Single Blog Post -->
<div id="single-news" class="reveal-modal single-news small" data-reveal>
    <?php
        $id = $_GET['id'];
        $member = mysql_query("SELECT*FROM team WHERE id = '".$id."'");
        while($m = mysql_fetch_array($member))
        {
    ?>  
        <div class="twelve columns first-column">
            <p class="single-news-content"><?php echo $m[quote]; ?></p>
        </div>
            <a class="close-reveal-modal">&#215;</a>
        </div>
    <?php } ?>