I need to delete certain lines of a text file by checkbox. my first script
<form method="post" action="delete.php">
<html>
<body>
<form method="post" action="delete.php">
<?php
$entirefile = file("../../write/248a.txt");
@$a = explode("|",$entirefile[0]);
sort($entirefile);
foreach ($entirefile as $k=>$v)
{
$a = explode("|",$v);
@list($category,$rating,$url,$description) = $a;
$category = htmlentities($category);
$url = htmlentities($url);
$description = htmlentities($description);
$rating = htmlentities($rating);
print ("<tr><td>$category</td><td>$rating</td><td><a href=\"http://$url\">$url</a></td><td>$description</td><td><input name= \"box$k\" type=\"checkbox\" value= \"1\"></td></tr><br>");
}
?>
</table>
<p>
<input value="Delete Checked Items" type="submit">
<input value="Reset" type="reset"></form>
</p>
<p>
<a href="index.php">Home</a>
</p>
</body>
</html>
My second script where I am having trouble
<?php
$file = file("../../write/248a.txt");
$fd = fopen("../../write/temp.txt","w");
sort($file);
foreach ($file as $k=>$v)
{
if (!isset($_POST['box$k']))
{
fwrite($fd,"$v");
}
}
unlink("../../write/248a.txt");
rename("../../write/temp.txt" , "../../write/248a.txt");
header("Location:248assignment10.php");
?>
How do I write a particular line that is checked instead of the whole file.