用变量删除表中的tr

时间:2014-03-23 11:06:24

标签: php

我试图在我的表中找到一个删除整个tr的函数,同时删除相应的$ variable = $ _POST ['variable'];和$ variable =“'。$ variable。'”;在我的页面中。

<?php
    require_once('common.php');
    checkUser();
    $page = 'traumato';
    include('header.php');
    ?>
    <?php
    include('vervaldata.php');
    if (isset($_POST['submit']))
            {
    // variabelen
    // REK A1
    $SPIRAALBLAD_HEUP = $_POST['SPIRAALBLAD_HEUP'];
    $DENSIPROBE_PFNA = $_POST['DENSIPROBE_PFNA'];
    $PFNA_BAK1 = $_POST['PFNA_BAK1'];
    $DFN_INSTR = $_POST['DFN_INSTR'];
    $DFN_IMPL = $_POST['DFN_IMPL'];
    // herschrijven             

    $fh = fopen('./vervaldata.php', 'w');
    fwrite($fh, '<?php 
    // REK A1
    $SPIRAALBLAD_HEUP = "' . $SPIRAALBLAD_HEUP . '";
    $DENSIPROBE_PFNA = "' . $DENSIPROBE_PFNA . '";
    $PFNA_BAK1 = "' . $PFNA_BAK1 . '";
    $DFN_INSTR = "' . $DFN_INSTR . '";
    $DFN_IMPL = "' . $DFN_IMPL . '";
    ?>');
    fclose($fh);
    // opslagen
    echo '<fieldset><p class="alert-box success"><span>Geslaagd: </span> Vervaldata werden aangepast!</p><meta HTTP-EQUIV="REFRESH" content="2; url=traumato.php"></fieldset>';}
    ?>


    <fieldset><form action="./traumato.php" method="post">
    <div class="alert-box2 box3"><b>VERVALDATA BERGING 2</b></div>
    <button class="save" type="submit" name="submit" value=" ">BEWAREN <img src="images/save.bmp"></button> <span class="tab"><img src="images/vervallen.bmp"> Reeds vervallen <img src="images/duewarn.png"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/vervallenwar.bmp"> Vervalt binnen 2 weken <img src="images/timewarn.png"></span>
    <table class="tablesorter" id="my-table" border="1" style="border-collapse:collapse">
            <thead>
                <tr>
                    <th>REK</th>
                    <th>BESCHRIJVING</th>
                    <th>VERVALDATUM</th>
                      <th>BEWERKEN</th>
                </tr>
            </thead>
            <tbody>
    <tr><td>A1</td><td>SPIRAALBLAD HEUP</td><td><?php echo $SPIRAALBLAD_HEUP; ?></td><td><input type="text" id="a11" class="datepicker" name="SPIRAALBLAD_HEUP" value="<?php echo $SPIRAALBLAD_HEUP; ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<button  class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>

    <tr><td>A1</td><td>DENSIPROBE PFNA</td><td><?php echo $DENSIPROBE_PFNA; ?></td><td><input type="text" id="a12" class="datepicker" name="DENSIPROBE_PFNA" value="<?php echo $DENSIPROBE_PFNA; ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<button  class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>

    <tr><td>A1</td><td>PFNA BAK 1/BAK 2</td><td><?php echo $PFNA_BAK1; ?></td><td><input type="text" id="a13" class="datepicker"  name="PFNA_BAK1" value="<?php echo $PFNA_BAK1; ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<button  class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>

    <tr><td>A1</td><td>DNF INSTRUMENTEN</td><td><?php echo $DFN_INSTR; ?></td><td><input type="text" id="a14" class="datepicker"  name="DFN_INSTR" value="<?php echo $DFN_INSTR; ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<button  class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>

    <tr><td>A1</td><td>DFN IMPLANTATEN</td><td><?php echo $DFN_IMPL; ?></td><td><input type="text" id="a15" class="datepicker"  name="DFN_IMPL" value="<?php echo $DFN_IMPL; ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<button  class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>

            </tbody>
        </table>
    </form>
    </fieldset>
    </body>
    </html>

我可以从表中删除一个tr,但我也想从我的脚本中删除变量。如果可能,我现在不知道吗?

提前thx。

2 个答案:

答案 0 :(得分:2)

您可以这样做:

if( !isset($remove_SPIRAALBLAD_HEUP)){ echo '<tr><td>A1</td><td>SPIRAALBLAD HEUP</td><td>'.$SPIRAALBLAD_HEUP.'</td><td><button></button></td></tr>'; }

现在,如果你给$remove_SPIRAALBLAD_HEUP任何错误,例如true,那么该行就不会被放到屏幕上。


另外,不要写PHP文件!这会产生重大风险,可用性就是垃圾。只需将数据写入文件(或数据库),下次需要时再次导入。您可能需要尝试serialize()json_encode()来获取数据。

答案 1 :(得分:0)

我不确定你的意思,但如果你想删除这一行

<tr><td>A1</td><td>SPIRAALBLAD HEUP</td><td><?php echo $SPIRAALBLAD_HEUP; ?></td><td><input type="text" id="a11" class="datepicker" name="SPIRAALBLAD_HEUP" value="<?php echo $SPIRAALBLAD_HEUP; ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<button  class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>

然后删除此行也是合乎逻辑的

 $SPIRAALBLAD_HEUP = $_POST['SPIRAALBLAD_HEUP'];

如果变量$SPIRAALBLAD_HEUP未在其他地方使用。此外,我建议您全文搜索整个源代码并删除该变量的所有其他用法以及设置$_POST['SPIRAALBLAD_HEUP']的部分。但同样,只有在其他地方没有使用它。