php - Update values inside database within a foreach html tag -


id' update $_post['commentaire'] in database. if put $comment = 'test'; it's working. right have $comment = $_post['commentaire'] , doesn't seems work...any idea? :s

if(isset($_post['confirmation'])){     $conf_arr = $_post['confirmation'];     $comment = $_post['commentaire'];     foreach($conf_arr $id => $conf) {         if($conf == 'accepter'){             $object = new user;             $object->changeit($conf,$id,$comment);         } else if($conf == 'refuser'){             $object = new user;             $object->changeit($conf,$id,$comment);         }        } }  public function admin(){         $st = $this->db->prepare("select * form");         $st->execute();         echo '<form action="compte.php" method="post">';         while($r = $st->fetch()){             $id = $r['id'];             echo '<hr>';             echo 'username : ' .$r['username'].' <br>';             echo 'adresse : ' .$r['adresse'].' <br>';             echo 'met : ' .$r['met'].' <br>';             echo 'age : ' .$r['age'].' <br>';             echo 'statut : ' .$r['statut'].' <br>';             echo '<input type="radio" name="confirmation['.$id.']" value="accepter"> accepter';             echo '<input type="radio" name="confirmation['.$id.']" value="refuser"> refuser<br><br>';             echo 'commentaire &agrave; transmettre : <br><textarea name="commentaire"></textarea>';             echo '<hr>';         }         echo '<input type="submit" name="submit" value="confirmer">';         echo '</form>';     }   public function changeit($ans,$id,$comment){         $st = $this->db->prepare("update `test`.`form` set `statut` = '$ans', `message` = '$comment' `form`.`id` = '$id'");         $st->execute();     } 

edit

i put form tag within while loop in admin() function. , seems work..this odd, don't understand why.

in index.php, how call function :

if(isset($_post['confirmation'])){     $conf_arr = $_post['confirmation'];     $comment = $_post['commentaire'];     foreach($conf_arr $id => $conf) {         if($conf == 'accepter'){             $object = new user;             $object->changeit($conf,$id,$comment);         } else if($conf == 'refuser'){             $object = new user;             $object->changeit($conf,$id,$comment);         }        } } 

but now, have problem. must select radio button $comment can update in database. if want stick same value radio btn (so select none of em) , want add value in $_post['commentaire']?


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -