如何在不重复几次的情况下显示表的TD?
我有一个具有表格的数据库。在此表中,有用户的名称,用户的号码,课程以及他所采用的水平。当用户上两个课程时,数据将重复两次(名称,编号),然后将其课程及其级别重复。我想在表中显示此数据库。我想在桌子的一行中有一个用户名和数字显示他的两个课程。
这是我的代码:
<table id="bootstrap-data-table-export" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>M Code</th>
<th>Numbering</th>
<th>Cours Level</th>
<th>Point</th>
<th>Graduation</th>
</tr>
</thead>
<tbody>
<%
var c =[]
//console.log(membre);
for (let i = 0; i < membre.length; i++) {
var element = membre[i];
//console.log("membre[i].username== ", membre[i].username);
for (let j = 0; j < c.length; j++) {
var element1 = c[j];
if (membre[i].username == c[j]) {
console.log("username = ", i,' ', element.username);
console.log("c[j] = ", j,' ', c[j]);
} else { %>
<% }
}
c.push(element.username)
%>
<tr>
<td>
<%= membre[i].username %>
</td>
<td>
<%= membre[i].mcode %>
</td>
<td>
<%= membre[i].num_agent %>
</td>
<td>
<select class="form-control selectPoints">
<option class="text-center" value="1"><%= membre[i].cours %> - niveau</option>
<option class="text-center" value="1">egal egal</option>
</select>
</td>
<td>
<div class="input-group">
<select class="form-control selectPoints">
<option class="text-center" value="1">Cours Name 5pts</option>
<option class="text-center" value="1">Cours Name 5pts</option>
</select>
<button class="btn btn-sm btn-success"><i class="fa fa-plus"></i></button>
<button class="btn btn-sm btn-danger"><i class="fa fa-edit"></i></button>
</div>
</td>
<td>
<div class="input-group">
<select class="form-control">
<option class="text-center" value="1">Bronze Excel</option>
<option class="text-center" value="">Silver Anglais</option>
</select>
<button class="btn btn-sm btn-success"><i class="fa fa-plus"></i></button>
<button class="btn btn-sm btn-danger"><i class="fa fa-edit"></i></button>
</div>
</td>
</tr>
<%
}; %>
</tbody>
</table>
I have a database that has a table. In this table there is the user's name, the user's number, the course, and the level he has taken. When the user takes two courses, the data is repeated twice (name, number) and then the course and its level. I would like to display this database in a table. I would like to have one username and number displaying his two courses in one row of the table.
It is my code:
<table id="bootstrap-data-table-export" class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>M Code</th>
<th>Numbering</th>
<th>Cours Level</th>
<th>Point</th>
<th>Graduation</th>
</tr>
</thead>
<tbody>
<%
var c =[]
//console.log(membre);
for (let i = 0; i < membre.length; i++) {
var element = membre[i];
//console.log("membre[i].username== ", membre[i].username);
for (let j = 0; j < c.length; j++) {
var element1 = c[j];
if (membre[i].username == c[j]) {
console.log("username = ", i,' ', element.username);
console.log("c[j] = ", j,' ', c[j]);
} else { %>
<% }
}
c.push(element.username)
%>
<tr>
<td>
<%= membre[i].username %>
</td>
<td>
<%= membre[i].mcode %>
</td>
<td>
<%= membre[i].num_agent %>
</td>
<td>
<select class="form-control selectPoints">
<option class="text-center" value="1"><%= membre[i].cours %> - niveau</option>
<option class="text-center" value="1">egal egal</option>
</select>
</td>
<td>
<div class="input-group">
<select class="form-control selectPoints">
<option class="text-center" value="1">Cours Name 5pts</option>
<option class="text-center" value="1">Cours Name 5pts</option>
</select>
<button class="btn btn-sm btn-success"><i class="fa fa-plus"></i></button>
<button class="btn btn-sm btn-danger"><i class="fa fa-edit"></i></button>
</div>
</td>
<td>
<div class="input-group">
<select class="form-control">
<option class="text-center" value="1">Bronze Excel</option>
<option class="text-center" value="">Silver Anglais</option>
</select>
<button class="btn btn-sm btn-success"><i class="fa fa-plus"></i></button>
<button class="btn btn-sm btn-danger"><i class="fa fa-edit"></i></button>
</div>
</td>
</tr>
<%
}; %>
</tbody>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论