php - 我如何使用 anchor 标记 href 打开我的代码的详细信息数据?

标签 php html mysql

我正在尝试在模型框中而不是新的 html 页面中打开从 php-mysql 获取的详细信息数据。目前它在其他 html 页面中打开,但我想将其添加到模型框中。

这是我当前的代码:

<a class="btn btn-info"  href="details.php?view_id=<?php echo $row['userID']; ?>" title="click for Details" onclick="details.php"><span class="glyphicon glyphicon-eye-open"></span> Show Details</a> 

这里它指的是 details.php?view_id 但模型示例是用 id 选择器找到的,如下所示,

<a href="#openModal">Show Details</a>
  <div id="openModal" class="modalDialog">
               <a href="#close" title="Close" class="close">X</a>
                <div>
                    <a href="#close" title="Close" class="close">X</a>
                    <h2>Modal Box</h2>

                </div>
            </div> 

如何添加 href="details.php?view_id=" 而不是 #openModel ??

我是新手,请帮忙

最佳答案

function edit_m_id(str){
  var xhttp;
    document.getElementById("edit_con_tent").innerHTML = "<center>loading.......</center>";
  xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("edit_con_tent").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "edit_m_con.php?q="+str, true);
  xhttp.send();   
}
<a href="#small-modal" onclick="edit_m_id('<?php echo $id_rand;?>')" data-toggle="modal">Edit</a>

<div id="small-modal" class="modal fade" role="dialog">
  <div class="modal-dialog">

   
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
       <span id='edit_con_tent'></span>
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

关于php - 我如何使用 anchor 标记 href 打开我的代码的详细信息数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46569306/

相关文章:

javascript - 使用php转换为json

php - 将 div 中的页面与 html 表单和 php 链接

html - 在不使用 HTML 的 SCSS 文件中编辑

mysql - 您的 PHP 安装似乎缺少 WordPress 所需的 MySQL 扩展。在 Ubuntu 14.04 LTS 上

mysql - MariaDb timediff 函数计算错误的小时数

php - imagecreatefromstring() [function.imagecreatefromstring] 此 PHP 版本中不支持 JPEG

php - 如何一个接一个地执行多个查询?

html - 在 Bootstrap header 内对齐右面板元素的正确方法

javascript - Javascript 更改文本后获取 TextBox 文本

mysql - 你能看出以下SQL注入(inject)防御方案中的漏洞吗?