Jump to content

Accept of Deny Lighbox Buttons


unemployment

Recommended Posts

I have created a lightbox where you can accept of deny friends.  Each friend that is displayed has approved or deny buttons next to them.

 

The approve button has a name like... approverequest[2] 

The delete button has a name like... denyrequest[2]

where 2 is the users id

 

My problem is that I can't get the data to update in mysql.  Am I going about this the wrong way?

 

if (isset($_POST['acceptrequest']))
{
if (is_array($_POST['acceptrequest'])) {
	$keys = array_keys($_POST['acceptrequest']);
	$id = $keys[0];

	$sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'";
	header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
}
}
else if (isset($_POST['denyrequest']))
{
if (is_array($_POST['denyrequest'])) {
	$keys = array_keys($_POST['denyrequest']);
	$id = $keys[0];

	$sql = "UPDATE `partners` SET `approved` = -1, `approved_date` = NOW() WHERE `user_id` = '$id'";
	header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
}
}

if (isset($sql) && !empty($sql))
{
mysql_query($sql);
}

Link to comment
Share on other sites

I think you forgot something

 

<?php
$sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'";
// after the previous line, you have to do this next line to update ur table

mysql_query($sql);
?>

Link to comment
Share on other sites

I think you forgot something

 

<?php
$sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'";
// after the previous line, you have to do this next line to update ur table

mysql_query($sql);
?>

 

I don't think so because I am using...

 

if (isset($sql) && !empty($sql))
{
mysql_query($sql);
}

 

UPDATE:  I forgot to add in friend_id

 

if (isset($_POST['acceptrequest']))
{
if (is_array($_POST['acceptrequest'])) {
	$keys = array_keys($_POST['acceptrequest']);
	$id = $keys[0];

	$sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id' AND `friend_id` = {$user_info['uid']}";
	header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
}
}
else if (isset($_POST['denyrequest']))
{
if (is_array($_POST['denyrequest'])) {
	$keys = array_keys($_POST['denyrequest']);
	$id = $keys[0];

	$sql = "UPDATE `partners` SET `approved` = -1, `approved_date` = NOW() WHERE `user_id` = '$id' AND `friend_id` = {$user_info['uid']}";
	header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] );
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.