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.

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

2nd page.

if (isset($_POST['checkboxReceipt'])){
   $sql="UPDATE payment SET";
      foreach ($_POST['checkboxReceipt'] as $key=>$value)
         $sql.=" Ref='xxx', date='xx-xx-xxxx' WHERE id='$checkedReceipt[$key]',";
         $sql=substr($sql,0,-1);
         $sql.=";";
   $run = mysql_query($sql);

Recommended Answers

All 3 Replies

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.

i think you have use check box in this way....

<input name="checkboxReceipt[]" value="<?php echo $frow['id']; ?>" type="checkbox"  />

Solved with code below.

foreach ($checkedReceipt as $key=>$value) {
     $sql="UPDATE payment SET Ref='xxx', date='xxxx-xx-xx'  WHERE id='$checkedReceipt[$key]'";	
  $run = mysql_query($sql);
Be a part of the DaniWeb community

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