I have the code:
PHP Code:<?php
$thefile = 'shouts.txt';
$dataf = 'shouts.txt';
$url = $_POST['url'];
$message = $_POST['message'];
function deleteLine($file, $lineNum) {
$c = file($file);
$c[$lineNum] = '';
$c = implode('', $c);
$f = fopen($file, 'w');
fwrite($f, $c);
fclose($f);
}
if(isset($_POST['Submit']))
$file = fopen("$dataf","a");
$write = fwrite($file,"<a href=$url>$message</a> ·· ($url)
");
fclose($file);
if(isset($_POST['lines']) && isset($_POST['del']))
for($i = 0; $i < count($_POST['lines']); ++$i)
deleteLine($thefile, $_POST['lines'][$i]);
$c = file('shouts.txt');
?>
<form action="<?php echo($PHP_SELF); ?>" method="post">
<?php for($i = 0; $i < count($c); ++$i) { ?>
<label style="display: block;">
<input type="checkbox" name="lines[]" value="<?php echo($i); ?>"><input type="submit" name="del" value="X">
<?php echo($c[$i]); ?>
</label>
<?php } ?>
#1<input name="message" size= "30" type="text" id="message">
#2<input name="url" size="30" type="text" id="url">
<input type="submit" name="Submit" value="Submit"><input type="reset" name="Reset" value="Reset">
</form>
I need to make it so that when you click on the button named "del" it will do the action of deleting the line... Currently it has to be set that the box has to be checked before it deletes, how do I make it so it doesn't need to be checked, just click the button next to it and it deletes the line?



Reply With Quote

Bookmarks