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 7611785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:44:57+00:00 2026-05-31T01:44:57+00:00

sorry if the title is a little.. vague i couldnt pin it down. So

  • 0

sorry if the title is a little.. vague i couldnt pin it down.

So i am developing a friend request system which works i guess similar in concept to facebook. So you get a request and it lists them without a page reload.

However i get the div ‘refreshing’ or so i think i cant test the php which is where i have a problem, i will post the relevent code and files below.

It may look a little long winded but it shouldnt be too bad in reality. My php code should keep executing the query which is looking at the database in the updateFriendBox.php however it doesnt seem to be doing this. My code may be messy as well so I apologise.

myaccount.php

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="javascript" type="text/javascript">
function refreshDiv()
{
    $.get('updateFriendBox.php', function(data){$('#refresh').html(data);});
}
$(function()
{
    refreshDiv();
    setInterval(refreshDiv, 5000);
});


function box(x){
    if($('#'+x).is(":hidden")){
        $('#'+x).slideDown(200);
    } else {
        $('#'+x).hide();
    }
}
</script>

<?php
$addBox = '<div style="display:inline; padding:5px;">
<a href="#" onclick="return false" onmouseup="javascript:box(\'fRequ\');">Show/Hide Friend Requests</a>
</div>';

// a bit further down in the code where its all called:

 <a href="#" class="tooltip"><? echo $addBox; ?></span></a>
          <div class="friendSlide" id="fRequ" style="height:240px; overflow:auto;">Your friend requests: <br />
          <div id="refresh"> <?php // this is where the refresh call is ?>
        </div>
        </center>
        </div>
</div>
</div>

updateFriendBox.php:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="javascript" type="text/javascript">
function acceptFriendRequest(x) {
    var url = "friendParse.php";
    $.post(url,{ request: "acceptFriend", reqID: x}, function(data){
        $("#req"+x).html(data).show().fadeOut(5000);
    });
}

function denyFriendRequest(x) {
    var url = "friendParse.php";
    $.post(url,{ request: "denyFriend", reqID: x}, function(data){
        $("#req"+x).html(data).show().fadeOut(5000);
    });
}
</script>
</head>
  <body>
        <?php
        include 'dbc.php';
        $sql = "SELECT * FROM friendRecu WHERE mem2='" . $_SESSION['user_id'] . "' ORDER BY id ASC LIMIT 10";
        $query = mysql_query($sql)or die(mysql_error());
        $num_rows = mysql_num_rows($query);
        if($num_rows < 1) { 
            echo "No friend requests";
        } else {
            while($row = mysql_fetch_array($query)){
                $requestID = $row['id'];
                $req = $row['mem1'];
                $sqlName = mysql_query("SELECT full_name FROM users WHERE id='$req'");
                while($row = mysql_fetch_array($sqlName)){
                    $requesterName = $row['full_name'];
                }
                echo '<hr /><table width="100%", cellpadding="5"><tr><td width="17%" align="left"><div style="overflow:hidden; height:50px; color:white;"></div></td> <td width="83%"><a href=viewmembers.php?uid=' . $req . '">' . $requesterName . '</a> added you as a friend
                <span id="req' . $requestID . '">
                <a href="#" onclick="return false" onmousedown="javascript:acceptFriendRequest(' . $requestID . ');">Accept</a>
                &nbsp; || &nbsp;
                <a href="#" onclick="return false" onmousedown="javascript:denyFriendRequest(' . $requestID . ');">Deny</a>
                </span></td></tr>
                </table>';
            }
        }
        ?>
  • 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-05-31T01:44:59+00:00Added an answer on May 31, 2026 at 1:44 am

    I think you are having a problem because your updateFriendBox.php is returning too much. Remove all that inline JS code, place it in an include file, and include it from myaccount.php. You also shouldn’t have <head> and <body> sections in your updateFriendBox.php file.

    The ajax call here doesn’t create a whole new page, you’re getting additional HTML to add to the original page.

    So the only thing you should have there is your SQL query, the loop, and your HTML output for each data row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the Title is a little vague but the truth is I do
Sorry if the title is a little vague, I do not know how else
Sorry if the title is a little vague, I have the following sceneraio: I
Sorry if the title is a little confusing. What I'm doing is creating a
Sorry if the post title wasn't clear, I will try to explain a little
I'm sorry if my title is a little unclear. Basically I want to print
Sorry for the bad title but it's a little complicated to get across in
Sorry the title is very vague. Basically, I'm stuck with something. I have an
So I'm sorry the title is so vague I'm not really even sure how
Sorry if the title of the question is a little misleading but I was

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.