0
我有2个数据表:
表1第二个数据表不显示 “无可用数据” 消息
<table id="properties_list" class="table">
<thead>
<tr class="backend_tab_header">
<th>Status</th>
<th>Photo</th>
<th>Property ID</th>
<th>Address</th>
<th>Date Created</th>
<th>Owner</th>
</tr>
</thead>
<tbody>
<?php
foreach ($properties as $property)
{
?>
<tr>
<td><?php print $property["status"]; ?></td>
<td class="pic_prop_table"><img class="img-responsive" src="<?php print $property["url"]; ?>" ></td>
<td><?php print $property["prop_id"]; ?></td>
<td><?php print $property["address"]; ?></td>
<td><?php print $property["date_created"]; ?></td>
<td><?php print $property["first_name"]; ?> <?php print $property["last_name"]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
表2
<table id="messages_list" class="table">
<thead>
<tr class="backend_tab_header">
<th>Property ID</th>
<th>Subject</th>
<th>Message</th>
<th>Received</th>
</tr>
</thead>
<tbody>
<?php
foreach ($properties as $property)
{
?>
<tr>
<td><?php print $messages["from_user"]; ?></td>
<td><?php print $messages["subject"]; ?></td>
<td><?php print $messages["message"]; ?></td>
<td><?php print $messages["date_sent"]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
,并填补了阵列叫我的PHP功能在页面顶部:
$properties = $auth_user->getPropertiesByUser($_SESSION['user_session']);
$messages = $auth_user->getMessages($_SESSION['user_session']);
数据表是用JS
jQuery(document).ready(function() {
jQuery('table#properties_list').DataTable({
//ajax: '../ajax/data/arrays.txt',
scrollY: 200,
scrollCollapse: true,
paging: false
});
jQuery('table#messages_list').DataTable({
//ajax: '../ajax/data/arrays.txt',
scrollY: 200,
scrollCollapse: true,
paging: false
});
});
我的问题是,当第一个数组($属性)返回空的第一个表显示消息“表中没有数据可用”,当两个数组($ properties和$ messages)返回空时,两个表都显示消息“表中没有可用数据”,但是当$ properties数组返回info和$ messages数组返回空时,第二个表(消息)不会显示“表中没有可用数据”,并且还会创建尽可能多的<td>
元素作为<td>
元素在第一张表(属性)。谁能告诉我这是什么原因? 在此先感谢
第二个调用看起来像引用$ properties而不是$ messages – Damon