I think I got a pretty good question. I produced a loop with 2 input radio button inside of each loop. When you press on one of these radio buttons, my function ChangeIt changes a value inside my database. This is where I am stuck : I have an ID column for each rows and I want to find that ID and put it into my ChangeIt function, into my statement (at the very end, I must put a dynamic ID). My Loop shows each rows inside of separated divs. I put a variable $id in my while loop, so I was thinking about, maybe, put my function ChangeIt inside my function Admin()? is this possible? THX!
Any ideas?
PHP on index.php
if(isset($_POST['confirmation'])){
$conf = $_POST['confirmation'];
if($conf == 'Accepter'){
$object = new User;
$object->ChangeIt($conf,$id);
} else if($conf == 'Refuser'){
$object = new User;
$object->ChangeIt($conf,$id);
}
}
PHP
public function Admin(){
$st = $this->db->prepare("SELECT * FROM form");
$st->execute();
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 '<form action="compte.php" method="post">';
echo '<input type="radio" name="confirmation" value="Accepter"> Accepter';
echo '<input type="radio" name="confirmation" value="Refuser"> Refuser<br>';
echo '<input type="submit" name="submit" value="Confirmer">';
echo '</form>';
echo '<hr>';
}
}
public function ChangeIt($ans,$id){
$st = $this->db->prepare("UPDATE `test`.`form` SET `Statut` = '$ans' WHERE `form`.`ID` = '$id'");
$st->execute();
}