栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

将PHP变量传递给引导模态

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

将PHP变量传递给引导模态

如果可以,我对你是正确的。

模态触发按钮

$row['ID']

$order .= '<td><a href="#myModal"  id="custId" data-toggle="modal" data-id="'.$row['ID'].'">Edit</a></td>';

Bootstrap Modal事件以

$row['ID']
使用Ajax方法获取值

$(document).ready(function(){    $('#myModal').on('show.bs.modal', function (e) {        var rowid = $(e.relatedTarget).data('id');        $.ajax({ type : 'post', url : 'fetch_record.php', //Here you will fetch records  data:  'rowid='+ rowid, //Pass $id success : function(data){ $('.fetched-data').html(data);//Show fetched data from database }        });     });});

模态HTML

<div  id="myModal" role="dialog">    <div  role="document">        <div > <div >     <button type="button"  data-dismiss="modal">&times;</button>     <h4 >Edit Data</h4> </div> <div >     <div ></div> //Here Will show the Data </div> <div >     <button type="button"  data-dismiss="modal">Close</button> </div>        </div>    </div></div>

最后创建

fetch_record.php
,检索记录并以模态显示

<?php//Include database connectionif($_POST['rowid']) {    $id = $_POST['rowid']; //escape string    // Run the Query    // Fetch Records    // Echo the data you want to show in modal }?>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/400728.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号