Google Answers Logo
View Question
 
Q: Text area PHP ( No Answer,   0 Comments )
Question  
Subject: Text area PHP
Category: Computers > Programming
Asked by: sjw-ga
List Price: $20.00
Posted: 30 Mar 2006 09:36 PST
Expires: 26 Apr 2006 08:26 PDT
Question ID: 713628
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>

Request for Question Clarification by palitoy-ga on 31 Mar 2006 00:24 PST
Can you please explain a little more what you require one of the
researchers to do?  Where does the comment field need to be?  What
should the comment field say?  Should the comment field be something
the user can see and enter themselves?  When will the comment be added
to the "line being removed"?

With answers to these questions I should be able to provide you with a
working solution.

palitoy-ga

Clarification of Question by sjw-ga on 31 Mar 2006 04:07 PST
The text field needs to be before the check box and would be for
comments. The user would need to be able to enter this themselves and
a single entry for each box check (marked to be removed from the first
file and moved the the "deleted" file). But also be able to enter
entries for multiple records at once. The comments should be appended
to the line when being "moved" to the "deleted" file. Right now, you
can checked multiple boxes and all the "checked" records are moved to
the "deleted" file, I do not want to lose that function or the ability
to check all the records at once to be removed. The end result should
be a new column that is a text area that appends to the file once
checked for removal. Does this help?
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy