我有MySQL表命名爲項目名爲項目名稱欄, 項目編號,項目狀態,項目開始日期,項目結束日期。 另外我有一個名爲'projects.php'的php頁面,我在頁面中顯示來自mysql表格項目的數據,但我只顯示前3列(項目名稱,項目編號,項目狀態)的數據。 同樣對於php表中的每一行,我都給出了一個鏈接,名爲查看點擊這將觸發一個模式。通mysql表數據來引導模式
我想顯示模態中特定行的所有列的數據。 請指導我如何繼續這種情況。
我對php,javascript,jquery很新。因此無法弄清楚如何將數據傳遞給模態。以下是可能有所幫助的代碼。
表中projects.php:
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Project Name</th>
<th>Project Number</th>
<th>Project Status</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT proj_name, proj_status, proj_num,
FROM Project";
$records = mysql_query($sql);
while ( $proj = mysql_fetch_assoc($records) )
{
echo "<td>".$proj['proj_name']." <a href='#testmodal' data-toggle ='modal'>view</a></td>";
echo "<td>".$proj['proj_num']."</td>";
echo "<td>".$proj['proj_status']."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
以下是我的模態碼:(這只是基本的一個)
<div class="modal" id="testmodal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title"><b>Test Modal</b></h3>
</div><!--end of modal-header-->
<div class="modal-body">
This is my test Modal !!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
您需要停止使用MySQL_ *函數,它們會被正式折舊。相反,你想看看[MySQLi](http://php.net/manual/en/class.mysqli.php)或[PDO](http://php.net/manual/en/class.pdo.php ) – Styphon