[56K WARN] Updating textarea in a Table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
da-Freq
Forum Newbie
Posts: 3
Joined: Sun May 20, 2007 6:24 pm

[56K WARN] Updating textarea in a Table

Post by da-Freq »

I have the table look like Image

My problem is I cannot get the "Job Gossip" column to update correctly. It doesn't matter what I enter for Jobs 39 and 40, they repeat the gossip from Jobs 35 and 36.

The code that produced the table:

Code: Select all

$i = 0;
foreach ($get_info as $field) {
  echo "<td><font face=arial size=1>";
  if($i==0){
    echo "<input name='jobID[]' value='$field' type='checkbox'>";
  }
  if($i==7) {
    echo "<textarea name='gossip[]'>$field</textarea>";
  }
  else {echo $field;}
  echo "</font></td>";
  $i++;
}
When the update button is clicked, it calls:

Code: Select all

$jobID = $_POST["jobID"];
$workerID = $_POST["workerID"];
$gossip = $_POST["gossip"];
for($i = 0; $i < count($jobID); $i++) {
  $update = "UPDATE job SET jobGossip = '".$gossip[$i]."' WHERE jobID = ".$jobID[$i];
  echo $update;
  $updateStatus = mysql_query($update,$link) or die("Update jobStatus Failed");
}
(I've omitted the lines that connects to the database).

I cannot seem to find where the bug is unfortunately. Any help would be greatly appreciated.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

what does your 'echo $update;' print ?
da-Freq
Forum Newbie
Posts: 3
Joined: Sun May 20, 2007 6:24 pm

Post by da-Freq »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I just tried to type:
fred
foo
boo
bar
yeh right
so what

into the 6 gossip fields.

The $update gave me:
[syntax="sql"]UPDATE job SET jobGossip = 'fred' WHERE jobID = 35
UPDATE job SET jobGossip = 'foo' WHERE jobID = 36
UPDATE job SET jobGossip = 'boo' WHERE jobID = 37
UPDATE job SET jobGossip = 'bar' WHERE jobID = 38
UPDATE job SET jobGossip = 'yeh right' WHERE jobID = 39
UPDATE job SET jobGossip = 'so what' WHERE jobID = 40
I then tried to update some of the fields:
fred is not human
foo is a cool word isn't it
yeh right, go jump
so what, who cares

(for jobs 35, 36, 39 and 40), and the echo $update now gives:

Code: Select all

UPDATE job SET jobGossip = 'fred is not human' WHERE jobID = 35
UPDATE job SET jobGossip = 'foo is a cool word isn\'t it' WHERE jobID = 36
UPDATE job SET jobGossip = 'boo and meh' WHERE jobID = 39
UPDATE job SET jobGossip = 'bar sells booze' WHERE jobID = 40
the "boo and meh", and "bar sells booze" comes from what I typed in jobs 37 and 38. but I did not "select" those jobs IDs -- i.e. the checkboxes corresponding to these two jobs were not selected, so I didn't know why they got passed through


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
blackbeard
Forum Contributor
Posts: 123
Joined: Thu Aug 03, 2006 6:20 pm

Post by blackbeard »

How are you passing the updated information back to the page?
da-Freq
Forum Newbie
Posts: 3
Joined: Sun May 20, 2007 6:24 pm

Post by da-Freq »

blackbeard wrote:How are you passing the updated information back to the page?
Sorry not sure what you mean?

I have a hyperlink at the bottom of the "update" package, which links (physically) back to the page with the table. I also tried to refresh the page.
Post Reply