dongtangxi1584 2012-11-18 16:57
浏览 26

使用无线电值删除xml文件

i using php to delete file, but i got table loop like this:

    <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 .'&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</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>

so as you can see i got radio value set has basename (xml file name) but from some reason it not working, any idea why is that?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • duanmangxie7131 2012-11-18 17:16
    关注

    It seems you are going about it in a wrong way.

    The PHP is server side, and cannot reach directly to the radio input seeing as it is client side.

    What you want requires a two step process: One for getting the page, and one for sending the radio input.

    Normally you would use jQuery/AJAX for something like this client side, and isolate the XML related code in a dedicated script server side.

    I hope that gets you in the right direction.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么