我有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