thoford75 0 Newbie Poster

Hi guys, I have a script that displays a list of tasks a user has to complete. To complete the task they must check the radio button and enter text into the textarea named eidtext.

Here is the form:

<form id="form151" name="form151" method="post" action="update/update-sales-taks.php?&user_id2=<?php echo $user_id2; ?>&user_id=<?php echo $user_id; ?>">

<?php  echo"<input name=\"salestasks\" type=\"hidden\" id=\"salestasks\" value=\"$division\" />"?>

<table width="100%" class="samples">
<tr>
<td>Task / Deadline</td>
<td>Complete / Outcome</td>
</tr>

<?PHP
$query = "SELECT event.eventcustomer,event.description,event.date_event,event.event_id,event.complete,event.notes,event.priority FROM event,dbACT WHERE event.cust_id=dbACT.ID AND dbACT.ID='$user_id2' AND event.user_id='$user_id' ORDER BY event.date_event ASC";
$result = mysql_query($query);
$index=0;

while(list($eventcustomer,$description,$deadline,$eid,$complete,$eidnotes,$priority) = mysql_fetch_row($result))
{ ?>
   
          <tr align="left">

<td><p align=center>
<input name="i[]" value="<?php echo $index; ?>" type="checkbox" checked="checked" style="display:none;" />
                      <?PHP echo $description;  ?> 
</p></td>
           
<td><p align=center>
<?PHP 
echo "<input type=\"hidden\" id=\"eid\" name=\"eid[]\" value=\"$eid\" />"; ?>
Check Circle If Complete
<input name="CB[]" value="<?php echo $index; ?>" type="radio" />

and Enter Text<br />

<?PHP echo "<textarea name=\"eidtext[]\" rows=\"3\" cols=\"25\" id=\"eidtext[]\"/>$complete</textarea>"; ?>

</td>

<?php 
$index++;
}   ?>

          </tr>
        </table>

<?PHP
   $query = "SELECT xAdditionalNotes FROM dbACT WHERE ID ='$user_id2'";
$result = mysql_query($query);
while(list($xAdditionalNotes) = mysql_fetch_row($result))
{
			
        echo "<input name=\"oldnotes\" type=\"hidden\" id=\"oldnotes\" value=\"$xAdditionalNotes\" />"; 
		
		} ?>
           
<input type="submit" name="submittasks" value="Update Tasks" />    
     
</form>

The form update page is:

<?PHP
$user_id = $_POST['salestasks'];
if($_GET['user_id']){
$user_id = $_GET['user_id'];
}

if($_GET['user_id2']){
$user_id2 = $_GET['user_id2'];
}

include "../includes/connect.php";

// get the eid array
$eid = $_POST['eid'];

// get the textbox array
$eidtext = $_POST['eidtext'];

$eiddesc = $_POST['eiddesc'];

$eidnotes = $_POST['eidnotes'];

$eidpriority = $_POST['eidpriority'];

$oldnotes = $_POST['oldnotes'];

// loop through the checkbox array
foreach($_POST['i'] as $item){
	
if (isset($_POST['CB']))
{ 

$xAdditionalNotesCB = gmdate("F j, Y, g:i") . ' *** Completed Task - ' . $eiddesc[$item] . ': ' . $eidtext[$item] . ' *** ' . '\n-------------------------\n' . $oldnotes;

$query = mysql_query("UPDATE event SET complete='$eidtext[$item]', clear='1', notes='$eidnotes[$item]', priority='$eidpriority[$item]' WHERE event_id='$eid[$item]'");

$query = mysql_query("UPDATE dbACT SET xAdditionalNotes='$xAdditionalNotesCB' WHERE dbACT.ID='$user_id2'");

header("Location: ../blankindex.php?page=view_tasks&user_id2=$user_id2&user_id=$user_id");

}
 
}
?>

Basically this checks to see if the radiobutton has been selected. If it has, then it updates the relevant row in the column 'complete'.

All this works great! However I want to update another table in my db (dbACT - column 'xAdditionalNotes') with (for example)

September 22, 2011, 11:08 *** Completed Task - Name of the task: text inserted by user ***

-------------

At the moment the only task that gets updated is the final task. For example if I have 5 tasks:

Task 1,2,3,4 & 5
and I complete each task with description a,b,c,d & e

In my database table event I will see:

event_id :1
description: 1
complete: 1
--
event_id :2
description: 2
complete: b
--
event_id :3
description: 3
complete: c
--
event_id :4
description: 4
complete: d
--
event_id :5
description: 5
complete: e


However in my xAdditionalNotes I will only see:

September 22, 2011, 11:08 *** Completed Task 5 - : e ***
-------------------------
September 22, 2011, 11:08 *** Completed Task - : ***
-------------------------
September 22, 2011, 11:08 *** Completed Task - : ***
-------------------------
September 22, 2011, 11:08 *** Completed Task - : ***
-------------------------
September 22, 2011, 11:07 *** Completed Task - : ***
-------------------------

As you can see the last task updates in the notes fine, but the first 4 do not...

HELP? :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.