2017-06-06 13 views
-1

我有一个包含来自数据库记录的“php页面”表。在每一行都有一个按钮,当我点击按钮时,应该会出现一个模态引导程序,其中包含有关您想知道的成员的详细信息。如何将GET值转换为引导模式

这是按钮的代码:

<td> <?php echo ' 
     <a href="?id='.$tabel_id.'" class="btn btn-primary">details</a>'; ?> </td> 

和模态引导代码:

<?php 
     $connect = mysqli_connect('127.0.0.1','root','','smart'); 
     $connect->set_charset("utf8"); 

     if(isset($_GET['id'])){ 
      $Mid = (int)$_GET['id']; 
     $getid = "select * from members where id = '$Mid'"; 
     $runid = mysqli_query($connect, $getid); 

     $row_id = mysqli_fetch_array($runid); 

    $show_name = $row_id['name']; 

    $show_number = $row_id['number']; 



    ?> 
    <div class="modal fade bd-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> 
    <div class="modal-dialog modal-lg"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
     <h5 class="modal-title" id="exampleModalLabel"> اضافة فاتورة</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 class="container"> 
        <div class="row"> 
        <form action="" method="post"> 

         <label>الاسم</label> 
         <input type="textbox" name="" class="Mname" disabled value="<?php echo $show_name ?>"></input> 
         <label>الرقم</label> 
         <input type="textbox" name="" class="Mname" disabled value="<?php echo $show_number; ?>"></input> 
         <label>النوع</label> 
         <select name="dbType" id="dbType"> 
         <option value="normal">عادي</option> 
         <option value="uargent">مستعجل</option> 
         </select> 
         <div id="otherType" style="display:none;"> 
         <label for="specify">Specify</label> 
         <input type="text" name="specify" placeholder="Specify Databse Type"/> 
         </div> 



        </form> 
        </div> 
       </div> 

     </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> 
<?php }else{echo'select an row please';} ?> 
     <script> 

$("#myModal").modal("show");</script> 

    <script src="/our/js/jquery.min.js"></script> 
    <script src="/our/js/bootstrap.min.js"></script>  
    <script src="/our/js/run.js"></script> 
</body> 

但是当我点击添加按钮的模式没有出现,但URL改变这样的:

http://localhost/our/dashboard.php#myModal?id=2

为什么模式不工作?

+0

哪来的jQuery函数/触发前加呢? – OldPadawan

回答

0

1.你有data-toggle='modal'但它不知道它应该打开什么样的模式。将此添加到您的按钮。

data-target='#myModal' 

Source


2.这也将触发模式。

$("#myModal").modal("show"); 

不能使用点击重定向你一个链接功能。

使链接正常只有href attr。

<?php echo '<a href="?id=$tabel_id">Button</a>'; ?>  

网址应该是仪表板?ID = 1个

HTML

<?php if(isset($_GET["id"])) { ?> 

    <div class="modal fade bd-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">  
     <!---Your same modal from your question--->  
    </div>  

<?php } ?> 

</body>结束标记

<script>$("#myModal").modal("show");</script> 
+0

我有puted上面的身体标记代码,但仍然无法正常工作 –

+0

我是一个新的引导,请解释更多我应该在哪里应该把代码 –

+0

@ F9oOol_11我编辑它 – Toni

相关问题