【问题标题】:Select table row to perform an action on that row选择表格行以对该行执行操作
【发布时间】:2017-11-02 23:35:30
【问题描述】:
这段代码生成了下图中的表格:
<table border='1' cellpadding='5' width='50%' bgcolor='lightyellow'>
<tr><th>Title of Training Course</th><th>Course Provider</th><th>Venue</th><th>Fee</th></tr>";
while ($row=mysql_fetch_array($result)){
echo "<tr align='center'>
<td>".$row['tcTitle']."</td>
<td>".$row['tcProvider']."</td>
<td>".$row['tcVenue']."</td>
<td>".$row['tcFee']."</td>";
}
如何选择一行以对该选定行执行操作?每行开头的单选按钮和什么?
我想选择一行并单击页面顶部的“安排”按钮来安排所选的培训课程。
【问题讨论】:
标签:
php
mysql
sql
html-table
【解决方案1】:
如果您不考虑多种选择,您可以使用常规的a href html 标签来调用包含您信息的页面。
请注意,您必须创建接受GET 请求的php 页面。
<table border='1' cellpadding='5' width='50%' bgcolor='lightyellow'>
<tr><th>Title of Training Course</th><th>Course Provider</th><th>Venue</th><th>Fee</th></tr>";
while ($row=mysql_fetch_array($result)){
echo "<tr align='center'>
// link the page and make query request with course name or id etc.
<a href='http://course_info.php?course='".$row['tcTitle']."><td>".$row['tcTitle']."</td></a>
<td>".$row['tcProvider']."</td>
<td>".$row['tcVenue']."</td>
<td>".$row['tcFee']."</td></tr>"; // ! CLOSE THE TAGS </tr>
}