php - 使用php mysql显示数据时缺少Datatable.js搜索栏
问题描述
我正在显示来自 mysql 数据库的记录,但每次加载数据时,表都搞砸了,表头上的排序功能丢失了,顶部的搜索栏也丢失了。
我尝试将纯 HTML 文本放到每个字段中,并且可以正常工作。我真的不知道为什么它不 php 代码不起作用。
<div class="row" style="margin-top:20px;">
<div class="col-sm-12">
<div class="panel panel-primary">
<div class="panel-heading">TEACHER LIST</div>
<div class="panel-body">
<table id="teacher-record" class="display" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>School Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $teacher as $user ) {
?>
<tr>
<td><?php echo $i+= 1; ?></td>
<td><?php
//Displays School Name
global $wpdb;
$teacher_email = $user->user_email;
echo display($teacher_email,4)
?></td>
<td><?php echo esc_html( $user->first_name ) ?></td>
<td><?php echo esc_html( $user->last_name ) ?></td>
<td><?php echo display($teacher_email,6) ?></td> -->
<td><?php echo esc_html( $user->user_email ) ?></td>
<td>
<button class="btn btn-success btn-view-shelf" data-id="<?php echo esc_html( $user->ID ); ?>">View</button>
<button class="btn btn-info btn-update-shelf" data-id="<?php echo esc_html( $user->ID ); ?>">Edit</button>
<button class="btn btn-danger btn-delete-shelf" data-id="<?php echo esc_html( $user->ID ); ?>" data-email="<?php echo esc_html( $user->user_email ); ?>">Delete</button>
</td>
<tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<th>ID</th>
<th>School Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
解决方案
推荐阅读
- python - Django:如何从在views.py 之外创建的views.py 访问会话数据
- angular - 使用 FormGroups 数组时,Angular 无法使用 FormGroup 找到控件
- microsoft-teams - 使用 API 列出 MS Teams 'Team' 中的频道名称以及每个频道的关联 'incoming-webhooks' url
- react-native - 使用 Telethon 获取电报个人资料照片
- javascript - AntD rowSelection 功能组件
- c - 仅使用单精度浮点在 [0,pi] 上逼近余弦
- ios - 使用全局变量和常量是一种好习惯吗?(斯威夫特 5)
- android - 华为推送套件:令牌在华为手机上返回为空
- docker - 无法通过 docker 中的 ssh 连接到 Corda 节点
- jquery - 如何用正确的 jquery 3.x 代码替换 thise .live 函数代码?