This script will add a submit button on the next line to remove that line, I have done this before but in this script i can not seem to get it to work. i know im missing something simple. Im tring to have the submit be an image and also put the button at the end of the line and not on the next line.
edit.php
<?php
$textFile = file("data.txt");
foreach($textFile as $key => $val) {
$line = @$line . $val . "<input type='submit' name=$key value='Delete'><br />";
}
$form = "<form name='form' method='post' action='deleter.php'> $line
</form>";
echo $form;
?>
deleter.php
<?php
$textFile = file("data.txt");
foreach($_POST as $key => $val) {
if($val == "Delete") {
$lines = count($textFile);
$textFile[$key] = "";
$fileUpdate = fopen("data.txt", "wb");
for($a=0; $a<$lines; $a++) {
fwrite($fileUpdate, $textFile[$a]);
}
fclose($fileUpdate);
}
}
header("Location:edit.php");
exit;
?>
This is what i have changed to get the image but of course it will not submit and have not found a way to add the image to the end of the line..
$line = @$line . $val . "<input type='image' name=$key src='delete.png' value='Delete'><br />";
Thank you