如何在不重复几次的情况下显示表的TD?

发布于 2025-02-03 06:59:13 字数 3500 浏览 1 评论 0原文

我有一个具有表格的数据库。在此表中,有用户的名称,用户的号码,课程以及他所采用的水平。当用户上两个课程时,数据将重复两次(名称,编号),然后将其课程及其级别重复。我想在表中显示此数据库。我想在桌子的一行中有一个用户名和数字显示他的两个课程。

这是我的代码:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文