douluo5937 2014-03-23 11:06
浏览 71
已采纳

用变量删除表中的tr

I am trying to find a function to delete an entire tr in my table and together delete also the according $variable = $_POST['variable']; and $variable = "' . $variable . '"; in my pagescript.

<?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>

I can delete a tr from the table but i want also the variables out of my script. I don now if this is possible??

thx in advance.

  • 写回答

2条回答 默认 最新

  • dongtingrun4973 2014-03-23 11:12
    关注

    You can do something like this:

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

    Now if you give $remove_SPIRAALBLAD_HEUP any false, like true, that line will not be put on the screen.


    Also, DONT WRITE PHP TO FILES! That creates major risks and the usebility is crap. Just write the data to the file (or database) and next time you need it, import it again. You might want to try serialize() or json_encode() for the data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号