Php 基于行号查询多个SlideIn函数
我正在寻找有关在MySQL查询生成的表上创建“更多详细信息”部分的最佳方法的信息,如下所示:Php 基于行号查询多个SlideIn函数,php,jquery,mysql,Php,Jquery,Mysql,我正在寻找有关在MySQL查询生成的表上创建“更多详细信息”部分的最佳方法的信息,如下所示: <tr> <th>First Name</th> <th>Surname</td> <th>Details</th> </tr> <tr> <td>Joe</td> <td>Blogs</td> <td><a
<tr>
<th>First Name</th>
<th>Surname</td>
<th>Details</th>
</tr>
<tr>
<td>Joe</td>
<td>Blogs</td>
<td><a class="button-1" href="">More Details</td>
</tr>
<tr>
<th class="hidden_details hidden-1" colspan="3">...insert details...</th>
</tr>
但我对JQuery的了解有限,因此我认为调用代码的唯一方法是使用php创建多个版本。如果有人能为我指明最佳方法的方向,我将不胜感激检查此代码。它会帮助你的。这里id=“view\u 1”,id=“show\u 1”1是数据库中的动态值
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<th>First Name</th>
<th>Surname</td>
<th>Details</th>
</tr>
<tr>
<td>Joe</td>
<td>Blogs</td>
<td><a class="button-1" id="view_1" href="javascript:void(0)" onclick="show_details(1)">More Details</td>
</tr>
<tr>
<th class="hidden_details hidden-1" colspan="3" id="show_1">...insert details...</th>
</tr>
<tr>
<td>Joe1</td>
<td>Blogs2</td>
<td><a class="button-1" id="view_2" href="javascript:void(0)" onclick="show_details(2)">More Details</td>
</tr>
<tr>
<th class="hidden_details hidden-1" colspan="3" id="show_2">...insert details...</th>
</tr>
</table>
<script type="text/javascript">
function show_details(id) {
if ($('#show_'+id).is(':visible')) {
$('#view_'+id).text('More Details');
$('#show_'+id).hide();
} else {
$('#view_'+id).text('Hide Details');
$('#show_'+id).show();
}
}
</script>
<style type="text/css">
.hidden_details {
display: none;
}
</style>
名字
姓
细节
乔
博客
更多细节
…插入详细信息。。。
Joe1
博客2
更多细节
…插入详细信息。。。
功能显示详细信息(id){
if($('#show'+id).is(':visible')){
$('#视图'+id).text('More Details');
$('#show'+id).hide();
}否则{
$('#视图'+id).text('Hide Details');
$('#show'+id).show();
}
}
.隐藏的详细信息{
显示:无;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<th>First Name</th>
<th>Surname</td>
<th>Details</th>
</tr>
<tr>
<td>Joe</td>
<td>Blogs</td>
<td><a class="button-1" id="view_1" href="javascript:void(0)" onclick="show_details(1)">More Details</td>
</tr>
<tr>
<th class="hidden_details hidden-1" colspan="3" id="show_1">...insert details...</th>
</tr>
<tr>
<td>Joe1</td>
<td>Blogs2</td>
<td><a class="button-1" id="view_2" href="javascript:void(0)" onclick="show_details(2)">More Details</td>
</tr>
<tr>
<th class="hidden_details hidden-1" colspan="3" id="show_2">...insert details...</th>
</tr>
</table>
<script type="text/javascript">
function show_details(id) {
if ($('#show_'+id).is(':visible')) {
$('#view_'+id).text('More Details');
$('#show_'+id).hide();
} else {
$('#view_'+id).text('Hide Details');
$('#show_'+id).show();
}
}
</script>
<style type="text/css">
.hidden_details {
display: none;
}
</style>