Hey, I'm trying to program a group-request system and now I'm struggling a little bit with the code. Well, I'll try my best to explain what I'm trying to do.
I want, that when I click the accept button, ONLY the name from the person next to the accept button is getting inserted into the SQL Database. Here is my code:
<?php
$servername = "localhost";
$dbname = "psychopath";
$username = "root";
$password = "";
try{
$dsn = "mysql:host=" . $servername . ";dbname=" . $dbname;
$db = new PDO($dsn, $username, $password);
echo "";
}catch(PDOException $e){
echo $e.getMessage();
}
$name = $_GET['name'];
$show_request =$db->prepare("SELECT * FROM group_requests WHERE view_status = 'unseen' AND accepted = 'no'");
$show_request->execute();
while($row=$show_request->fetch()){
$sender = $row['request_sender'];
echo "<b>$sender</b><form method='get'><input type='submit' name='accept' id='accept' value='accept'/><a></a></form><br>";
}
?>
I think, if I can get the $sender variable out of the while loop, than it should work, or? How you can see, I'm not sure how I can fix the problem. Hope, you guys can help :)