Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:08:03+00:00 2026-06-07T16:08:03+00:00

I am struggling with a solution to my problem. I have created the code

  • 0

I am struggling with a solution to my problem. I have created the code and works fine in PHP but I now want to evolve this into a better working solution for the end user.

I have a set of links to confirm or deny an action. Once the users clicks “Confirm”/”Deny” I would like this to save value to db using AJAX and then make the li animate out with jQuery.

At the moment i have used php, which redirects to URL. Any help/guidance would be greatly appreciated.

Heres my code:

links

           <?php    

            $friend_unconfirmed_from_them = mysql_query('
            SELECT * from wallfriends 
            where mem_id_to ='.$USER->id.' AND confirm = 0
            '); //unconfirmed friends to logged in user ($USER->id)

        while ($friendrequest = mysql_fetch_array($friend_unconfirmed_from_them, MYSQL_ASSOC)) { 


        $senders_name = mysql_query('
            SELECT firstname, lastname from mdl_user 
            where id = '.$friendrequest['sender'].'
            '); //get unconfirmed friends name

        while ($sender = mysql_fetch_array($senders_name, MYSQL_ASSOC)) { 
            ?>

        <li><?php echo $sender['firstname'].'&nbsp;'.$sender['lastname']; 
            }?>            
        <a href="confirmfriend.php?userid=<?php echo $friendrequest['sender']; ?>">Confirm Link</a>
        &nbsp;<a href="removefriend.php?userid=<?php echo $friendrequest['sender']; ?>">Deny Link</a></li> 
//echo each friend in li with confirm deny links
            <?php } ?>

        </ul>  

confirmfriend.php

$userid = optional_param('userid', 0, PARAM_INT);


$connection = mysql_connect("localhost", "root", "on10n") or die ("Unable to connect!");   
mysql_select_db("fe") or die ("Unable to select database!");    
$query = "UPDATE wallfriends SET confirm = 1 WHERE mem_id_to = '$USER->id' AND mem_id_from = '$userid'";    

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (!$result){
    echo "There were errors :<br>". mysql_error();
} 
else{ 
redirect($siteUrl.'/profile.php?userid='.$userid.'');
die;  
}

denyfriend.php

$userid = optional_param('userid', 0, PARAM_INT);


$connection = mysql_connect("localhost", "root", "on10n") or die ("Unable to connect!");   
mysql_select_db("fe") or die ("Unable to select database!");    

$query = "DELETE FROM wallfriends 
WHERE (mem_id_from = '$USER->id' OR mem_id_from = '$userid') 
AND (mem_id_to = '$USER->id' OR mem_id_to = '$userid') 
";    

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

if (!$result){
    echo "There were errors :<br>". mysql_error();
} 
else{ 
redirect($siteUrl.'/profile.php?userid='.$userid.'');
die;  
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:08:05+00:00Added an answer on June 7, 2026 at 4:08 pm

    youre not showing any javascript and the anchor will throw the page onto confirmfriend.php/removefriend.php.

    Also you have multiple nested anchor tags (remember to close with </a>)

    To achieve desired result, i’d do so:

    <li>
      <a href="javascript:void(0);" class="confirm friendaction"
          data-userid="<?php echo $friendrequest['sender'];>">Confirm</a>
    </li><li>
      <a href="javascript:void(0);" class="remove friendaction"
          data-userid="<?php echo $friendrequest['sender'];>">Remove</a>
    </li>
    

    Followed by a script which hooks onclick to anchors, sending an AJAX request.

    <script>
       $('.friendaction').click(function() {
           var id = this.getAttribute('data-userid'),
               url = this.className.match("confirm") 
                  ? "confirmfriend.php" 
                  : "removefriend.php", 
               liReference = $(this).parent();
           $.ajax(url + "?userid=" + id, {
               complete: function() {
                  $(liReference).fadeOut();
               }
           });
       });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling to find a solution to this problem. In my code,
This is a basic question but I am struggling to find a decent solution.
I have been struggling with this seeminly easy problem for 48 hours, and I
I've been struggling with this problem for 5 hours and I have a feeling
I'm struggling to figure out a solution to my problem, I have a Download
I'm currently struggling with this problem. The situation is that I have a user
We are struggling with a problem that is driving me insane. Using this code...
I've been struggling with the following problem for some days now. I have found
I have been struggling with a problem for a while and so far have
I have been struggling with a problem I have with Axis2 and Rampart for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.