Php 在特定编码后,如何显示表格?
我已经这样编码了,在上传excel文件时,excel中的数据列表将显示在表中Php 在特定编码后,如何显示表格?,php,mysql,Php,Mysql,我已经这样编码了,在上传excel文件时,excel中的数据列表将显示在表中 <?php $res=mysql_query("SELECT * FROM dealer_tbl"); $count =mysql_num_rows($res); ?> <table class="table" <?php if($count == 0) { ?> style="display:none;" <?php }?>> ...
<?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>
现在的问题是删除数据,下面的特定行将单独显示
<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");
$count =mysql_num_rows($res);
?>
<table class="table" <?php if($count == 0) { ?> style="display:none;" <?php }?>>
...
</table>
我希望仅当有多行时才显示整个表。请帮我做这个
<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
$res=mysql_query("SELECT * FROM dealer_tbl");
$count =mysql_num_rows($res);
?>
<table class="table" <?php if($count == 0) { ?> style="display:none;" <?php }?>>
...
</table>
试试这个。您可以从表单外部的查询中获取行数,如果行数大于0,则可以显示结果
<?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
$res=mysql_query("SELECT * FROM dealer_tbl");
$num_rows = mysql_num_rows($res);
if($num_rows>0)
{
?>
<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
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
}
else
{
echo "No result Found !! ";
}
?>
注意:mysql_*现在已不推荐使用,因此请使用mysqli_*或PDOmysql_*查询已过时。看见您应该使用PDO或mysqli_
<?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>