I need to add a comment field that appends to the line being removed
in the code below, can someone help me out
<html>
<head>
<title>Postings</title>
<title>Testing - Not For Use Yet</title>
</head>
<body bgcolor="#0000FF">
<script language="JavaScript" src=checkall.js></script>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href='pending.php'><font color="#000000"><b>Pending
Posts</font></a></td>
<td><center><b><h1><a href='index.php'><font
color="#000000">Current Posts</font></a></td>
<td><div align="right"><a href='resolved.php'><font
color="#000000">Past Posts</font></a></div></td>
</tr>
<table border="1" width="100%" >
<tr>
<td>
<?php
$path_to_dir = 'post'; // path to text file
$file_contents = file("$path_to_dir/posts.txt"); // the file
$file_contents_deleted = file("$path_to_dir/past-posts.txt"); // the file
// [ DELETE ROUTINE ]
if($_POST['action'] == "delete"){ // delete triggered
$arrToDelete = $_POST['todelete']; // assign checked items array to var
if($arrToDelete != "") { // if the array isnt open proceed
foreach($arrToDelete as $key => $value) { // assign a key and value to
each checked item
$file_contents_deleted[] = $file_contents[$key];
array_splice($file_contents, $key, 1, ""); // assign null value to
each checked item in file_contents array
print("<font color=#00FF40>Removed <b> $value </b>Posts From Pending
List</font><br>");
}
$sizeof = count($file_contents_deleted); // count updated file_contents array
if($filehandle = fopen("$path_to_dir/past-posts.txt", "w")){ // open
the file for writing
for($y = 0; $y < $sizeof; $y++){ // loop through the new file_contents array
if($file_contents_deleted){
fputs($filehandle, $file_contents_deleted[$y]); // write the new
file_contents array to the file
}
}
fclose($filehandle); // close the file
}
$sizeof = count($file_contents); // count updated file_contents array
if($filehandle = fopen("$path_to_dir/posts.txt", "w")){ // open the
file for writing
for($y = 0; $y < $sizeof; $y++){ // loop through the new file_contents array
if($file_contents){
fputs($filehandle, $file_contents[$y]); // write the new file_contents
array to the file
}
}
fclose($filehandle); // close the file
}
}
}
?>
<?php // [ READ & OUTPUT FILE CONTENTS ] ?>
<!-- The Form & Table -->
<form name=binform method="POST" action="<?php $PHP_SELF ?>" style="margin:0;">
<input type="hidden" name="action" value="delete">
<table border="1" width="100%" bgcolor="#000000">
<tr>
<td class="spectable" bgcolor=#FFFF00><center><b><h2><a href="<?php
$PHP_SELF ?>?sort=bin"><font color=000000>User</a></td>
<td class="spectable" bgcolor=#FFFF00><center><b><h2><a href="<?php
$PHP_SELF ?>?sort=bintype"><font color=000000>Name</a></td>
<td class="spectable" bgcolor=#FFFF00><center><b><h2><a href="<?php
$PHP_SELF ?>?sort=user"><font color=000000>Email</a></td>
<td class="spectable" bgcolor=#FFFF00><b><h2><center>Posts To Remove</td>
</tr>
<?php
$file_contents = file("$path_to_dir/bins.txt"); // the file
foreach($file_contents as $key=> $value){ // assign a key to each line in the file
if($file_contents[$key] != ""){
$entry = explode("\t", $file_contents[$key]); // break out each
delimeter - tab in this case
$entries[]=array('user'=>$entry[0], 'name'=>$entry[1],
'email'=>$entry[2],'key'=>$key, 'value'=>$value);
}
}
if ($entries) {
foreach ($entries as $key => $row) {
$bin[$key] = $row['user'];
$bintype[$key] = $row['name'];
$user[$key] = $row['email'];
}
switch ($sort) {
case "user": array_multisort($user, SORT_ASC, $entries); break;
case "name": array_multisort($name, SORT_ASC, $entries); break;
case "email": array_multisort($email, SORT_ASC, $entries); break;
}
}
for($i=0; $i<sizeof($entries); $i++) {
print("<tr>
<td class=spectable bgcolor=FFFF00><h4><center>".$entries[$i]['user']."</td>
<td class=spectable bgcolor=FFFF00><h4><center>".$entries[$i]['name']."</td>
<td class=spectable bgcolor=FFFF00><h4><center>".$entries[$i]['email']."</td>
<td class=spectable bgcolor=FFFF00><h4><center><input type=checkbox
name=todelete[".$entries[$i]['key']."]
value=".$entries[$i]['value']."></center></td>
</tr>");
}
?>
<tr>
<td colspan="3" align="center" class="spectable"
bgcolor=FFFF00><h4><center><input type="submit" value="Remove Post(s)
From List"></td>
<td align="center" class="spectable" bgcolor=FFFF00><b>Check All
<input onclick="check_all_ch_1();" name="all_ch_1" type=checkbox>
?</td>
</tr>
</table>
</form>
</td>
</table>
<br><br><br> |