Friend accepting php forms

Basically im creating a simple friend request and accepting form using mysql and php.

i already have it set up so you type in the friends username and hit enter, and then it inserts your username and theirs into a “peerrequests” DB twice with a “1” for the status for one row and a “0” for the other.

Right now im having a problem accepting and denying the friendships.

I would like to have a table with 3 columns, the requesting friend username, an accept button, and a deny button.
THe table will obviosly have to automatically add rows based on how many requests you have pending.

When accepted, it should erase the involved rows from the “peerrequest” table and insert 2 more rows into a “peerconfirmed” table with 1’s as status’.

I am unable to make the buttons update only the row they belong to, i know i need to do some sort of counting to individually name each button but i am new to php and i have yet to figure it out.
ive gone with a very modular approach because i though it would be simpler, but it hasnt helped. heres my code

THe Mysql tables are both set up as

ID----peer1----Peer2----Status
1-----test1-----test2--------1
2-----test2-----test1--------0

the listing and table php section is

[php]
$username = $_SESSION[‘SESS_USER_NAME’];

$qry = “SELECT * FROM peerspending WHERE peer1 = ‘$username’ AND status = ‘0’”;
$result = mysql_query($qry);

echo “

”;
echo "



";

while ($row = mysql_fetch_array($result)) {

 // Print out the contents of each row into a table
 echo "<tr><td>";
 echo $row['peer2'];

 echo "</td><td>";
 echo "<form action='peerAccept.php' method='post'><input id='peerButton' type='submit' name='submit'       value='Accept'></form>";

 echo "</td><td>";
 echo "<form action='peerDeny.php' method='post'><input id='peerButton' type='submit' name='submit'      value='Accept'></form>";

 echo "</td></tr>";

}
echo “

Username

Accept

Deny

”;

?>[/php]

The peer accept and deny forms would both be very similar, the accept would delete the rows from the peerspending mysql table and insert rows to the peersconfirmed mysql table. while the peerdeny form would only delete the rows.

I am unable to make the forms function only within their specific row in the html table.
i know there should be some sort of counter, or possibly utilize the primary key but im lost as to how to implement it.

I know im missing some variables but i threw this together so you can help me set them.
Any help or advise you can give would be greatly appreciated, i realize i reposted this sortof, but i changed a lot of what i was doing and am posting it a more relative section. (im new to this as well lol)

Sponsor our Newsletter | Privacy Policy | Terms of Service