我已經搜索了很多,但仍然有一些問題將唯一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