我已经搜索了很多,但仍然有一些问题将唯一ID传递给Value,然后使用该ID用于PHP MySQL Query以获取图书信息。Twitter Bootstrap - 将唯一ID传递给Modal
我目前正在将唯一ID传递给模态并通过输入类型文本显示它。我只是有一个很难搞清楚如何把ID为可变一个PHP
这里是我的HTML/PHP代码
echo '<a data-toggle="modal" data-id="' . $book_id .'" title="Add this item" class="open-AddBookDialog btn btn-primary" href="#addBookDialog">View Info</a>';?>
<!-- Modal -->
<div class="modal hide" id="addBookDialog">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>Book Info</h3>
</div>
<div class="modal-body">
<p>some content</p>
<?php
echo $test = '<input type="text" name="bookId" id="bookId"/>';
$book_info = get_book_info($book_id);
while($row1 = mysqli_fetch_array($book_info))
{
$email = $row['email'];
echo "<p><strong>Title: </strong>" . $row1['title'] . "</p>";
echo "<p><strong>Author: </strong>" . $row1['author'] . "</p>";
echo "<p><strong>Edition: </strong>" . $row1['edition'] . "</p>";
echo "<p><strong>ISBN: </strong>" . $row1['isbn'] . "</p>";
echo "<p><strong>Price: </strong>" . $row1['price'] . "</p>";
echo "<p><strong>Seller's Name: </strong>" . $row1['name'] . "</p>";
echo "<p><strong>Seller's E-mail: </strong><a href='mailto:$email'>$email</a></p>";
}?>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
,这里是我的jQuery
$(document).on("click", ".open-AddBookDialog", function() {
var myBookId = $(this).data('id');
$(".modal-body #bookId").val(myBookId);
});
我DONOT明白你的问题。你能否告诉我们你的具体问题是什么以及你已经尝试了什么? – Reflic 2013-05-05 21:18:54
我的问题是传递一个PHP变量到一个模态,然后阿拉伯联合酋长国的查询来显示有该ID的书的信息 – user1536365 2013-05-05 21:30:24