我使用php删除文件,但我得到了这样的表循环:
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
<tr class="bg_tableheader">
<th class="table-header-check"><a id="toggle-all" ></a> </th>
<th class="table-header-check"><a href="#"><font color="white">Username</font></a> </th>
<th class="table-header-check"><a href="#"><font color="white">First Name</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Last Name</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Email</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Group</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Birthday</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Gender</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Age</font></a></th>
<th class="table-header-check"><a href="#"><font color="white">Country</font></a></th>
</tr>
<?php
$files = glob('users/*.xml');
foreach($files as $file){
$xml = new SimpleXMLElement($file, 0, true);
echo '
<tr>
<td></td>
<form action="" method="post">
<td class="alternate-row1"><input type="radio" name="file_name" value="'. basename($file, '.xml') .'" />'. basename($file, '.xml') .'</td>
<td>'. $xml->name .'          </td>
<td class="alternate-row1">'. $xml->lastname .'</td>
<td>'. $xml->email .'</td>
<td class="alternate-row1">'. $xml->level .'</td>
<td>'. $xml->birthday .'</td>
<td class="alternate-row1">'. $xml->gender .'</td>
<td>'. $xml->age .'</td>
<td class="alternate-row1">'. $xml->country .'</td>
</tr>';
}
?>
</table>
</div>
<?php
if(isset($_POST['file_name'])){
unlink('users/'.$_POST['file_name']);
}
?>
<input type="submit" value="Delete" />
</form>
所以你可以看到我的无线电值集有basename(xml文件名)但由于某种原因它不起作用,知道为什么吗?
提前致谢。