gpt4 book ai didi

php - 在特定条件后如何显示表格?

转载 作者:行者123 更新时间:2023-11-30 00:38:05 25 4
gpt4 key购买 nike

我是这样编码的,上传Excel文件时,Excel中的数据列表将显示在表格中。

现在的问题是删除数据,下面的特定行单独显示。

<tr>
<th>Title</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Phone</th>
<th>Options</th>
<th><input type="checkbox" name="delete_all" class="" value='' onClick="deleteAll()" /></th>
</tr>

我希望仅当超过一行时才显示整个表格。请帮我解决这个问题。

<form name="del_functionality" method="post" action="<?php echo $_SERVER['PHP_SELF'];     ?>">
<div class="control-group">
<div class="controls" align="right">
<button type="submit" id="deletes" name="delete" value="delete" data-loading-text="Loading..." onClick="return deleteSelected()">Delete </button>
</div>
</div>

<table class="table">
<tr>
<th>Title</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Phone</th>
<th>Options</th>
<th><input type="checkbox" name="delete_all" class="" value='' onClick="deleteAll()" /></th>
</tr>
<?php
$res=mysql_query("SELECT * FROM dealer_tbl");
while($dealer_row=mysql_fetch_array($res))
{
?>
<tr>

<td><?php echo $dealer_row['title']; ?></td>
<td><?php echo $dealer_row['firstname']; ?></td>
<td><?php echo $dealer_row['lastname']; ?></td>
<td><?php echo $dealer_row['email']; ?></td>
<td><?php echo $dealer_row['phone']; ?></td>
<td align="center"><a href='dealer_edit.php?did=<?=$dealer_row['uid']?>'>Edit</a> </td>
<td>
<input type="checkbox" name="checkbox_del[]" class="deleteCheckbox" value="<?php echo $dealer_row['uid']; ?>" />
<input type='hidden' name='deleteConfirm' value='0' />
</td>
</tr>
<?php
}
?>
</table>
</form>

最佳答案

更改查询位置,如下所示:

<?php 
$res=mysql_query("SELECT * FROM dealer_tbl");
$count =mysql_num_rows($res);
?>
<table class="table" <?php if($count == 0) { ?> style="display:none;" <?php }?>>
...
</table>

关于php - 在特定条件后如何显示表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22006172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com