Updating selected Checkbox problem

Thread Solved

Join Date: Apr 2008
Posts: 496
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Updating selected Checkbox problem

 
0
  #1
Aug 3rd, 2008
Hi,
When i click one checkbox code below workes fine but, more than one, noo. I cant find the problem. Can you help me please?
Thnaks

1st page.
  1. <td><input type="checkbox" name="checkboxReceipt<?php echo "[$newArray[id]]"; ?>" value="<?php echo $newArray['id']; ?>" id="checkboxReceipt"></td>

2nd page.
  1. if (isset($_POST['checkboxReceipt'])){
  2. $sql="UPDATE payment SET";
  3. foreach ($_POST['checkboxReceipt'] as $key=>$value)
  4. $sql.=" Ref='xxx', date='xx-xx-xxxx' WHERE id='$checkedReceipt[$key]',";
  5. $sql=substr($sql,0,-1);
  6. $sql.=";";
  7. $run = mysql_query($sql);
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: Updating selected Checkbox problem

 
0
  #2
Aug 3rd, 2008
Just by breezing over the code, it looks like you are trying to update one row with two or more values. If so, you'll have to concatenate them before the update.
Lost time is never found again.
- Benjamin Franklin
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Updating selected Checkbox problem

 
0
  #3
Aug 4th, 2008
i think you have use check box in this way....
  1. <input name="checkboxReceipt[]" value="<?php echo $frow['id']; ?>" type="checkbox" />
Last edited by Shanti Chepuru; Aug 4th, 2008 at 4:23 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 496
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Re: Updating selected Checkbox problem

 
0
  #4
Aug 4th, 2008
Solved with code below.

  1. foreach ($checkedReceipt as $key=>$value) {
  2. $sql="UPDATE payment SET Ref='xxx', date='xxxx-xx-xx' WHERE id='$checkedReceipt[$key]'";
  3. $run = mysql_query($sql);
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC