您可以使用AJAX来完成。了解这些:
http://www.w3schools.com/ajax/
http://php.net/manual/zh/mysqli.quickstart.prepared-
statements.php
准备好的语句将使您免受SQL Injection攻击。如果要查询的是来自用户的输入,请练习专门使用它。
的HTML
<a href="#myModal" data-toggle="modal" id="78" data-target="#edit-modal"> <button type="button"> <i ></i> </button></a><div id="edit-modal"> <div ></div></div>
PHP(content.php)使用程序化mysql
<?php $er = $_POST['id']; $str = "SELECt * FROM examquestion WHERe EQ_ID = '$er' "; $Recordset7 = mysql_query($str) or die(mysql_error()); $row_Recordset7 = mysql_fetch_assoc($Recordset7); echo $row_Recordset7['EQ_ID']; ?>
PHP使用OOP mysqli(准备好的语句)
$mysqli = new mysqli("localhost", "user", "password", "database");$query = "SELECt content FROM examquestion WHERe EQ_ID = ?";if ( $stmt = $mysqli->prepare($query) ){ $stmt->bind_param("s", $er); if ( $stmt->execute() ) { $stmt->bind_result($content); while ($stmt->fetch()) { echo $content; } } $stmt->close();}
JS
<script> $('a.get-content').click(function() { var contentId = $(this).attr('id'); var modalId = $(this).attr('data-target'); $.ajax({ url: "content.php", type: "POST", data: {id: contentId}, dataType: "html", success:function(data){ $(modalId).find('.edit-content').eq(0).html(data); } }); });</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)