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"> <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; ?>"> <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; ?>"> <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; ?>"> <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; ?>"> <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; ?>"> <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.
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.
I am not really sure what you mean, but if you want to delete this line
<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; ?>"> <button class="savelink" type="submit" name="submit" value=" "><img src="images/save2.png"></button></td></tr>
Then it is logical to delete this line as well
$SPIRAALBLAD_HEUP = $_POST['SPIRAALBLAD_HEUP'];
if the variable $SPIRAALBLAD_HEUP
is not used somewhere else. Moreover, I suggest you fulltext-search your entire source code and remove all the other usages of that variable also the part that sets $_POST['SPIRAALBLAD_HEUP']
. But again, only if it is not used somewhere else.