在bootstrap模式3中保存按钮

时间:2014-10-29 21:35:41

标签: php twitter-bootstrap-3 bootstrap-modal

如果我点击"更改"在de modal中的按钮,它们将关闭,我的数据库中没有任何更新。

首先,应该在数据库中更新数据,之后我想向用户显示数据已保存。然后用户可以按“关闭”键。点击模式上的按钮可以关闭模​​态框架外的模态。

这是我打开模态的链接:

<a href="#" data-id="1" class="btn btn-primary showme">Show Me</a>

这是我的Jquery ajax脚本:

<script type="text/javascript">
jQuery(function($){
     $('a.showme').click(function(ev){
         ev.preventDefault();

         var uid = $(this).data('id');
         var uid2 = $(this).data('id2');

         $.get('test-modal.php?id=' + uid + '&id2=' + uid2, function(html){
             $('#modal-7 .modal-body').html(html);
             $('#modal-7').modal('show', {backdrop: 'static'});
         });
     });
});
</script>

这是我的模态代码:

<div class="modal fade" id="modal-7">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Dynamic Content</h4>
            </div>

            <div class="modal-body">

                Content is loading...

            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">Close</button>

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

test-modal.php的代码:

<?php
$id = $_GET['id'];
$id2 = $_GET['id2'];

require ('config.php');

     $conn = mysql_connect($host,$user,$pass) or die (mysql_error());
     mysql_select_db($dbnm) or die (mysql_error());

     $sql = "SELECT * FROM historiek WHERE id = '". $id ."'";
     $res = mysql_query($sql) or die (mysql_error());

     while($row = mysql_fetch_assoc($res)) { 
     ?>

      <div class="row">
        <form role="form" method="post">

            <div class="form-group">
                <textarea class="form-control ckeditor" id="editor10" name="historiek" rows="10"><?php echo $row['historiek']; ?></textarea>
            </div>

            <div class="form-group">
                <button type="submit" name="Submit" class="btn btn-info">Change</button>
            </div>

        </form>
      </div>


<?php

if (isset($_POST['Submit'])) {

$id = $_GET['id'];
$historiek = $_POST['historiek'];

require ('config.php');

     $conn = mysql_connect($host,$user,$pass) or die (mysql_error());
     mysql_select_db($dbnm) or die (mysql_error());

     $sql = "UPDATE historiek SET historiek = '$historiek' WHERE id = '". $id ."'";
     $res = mysql_query($sql) or die (mysql_error());

}
?>

有人可以帮助我吗?

0 个答案:

没有答案