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

  • Home
  • SEARCH
  • 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 6074697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:24:40+00:00 2026-05-23T10:24:40+00:00

Peter have sent request to Michelle by clicking add friend button on Michelle’s page,

  • 0

Peter have sent request to Michelle by clicking “add friend” button on Michelle’s page, database table tbl_frienRequest store Peter at “user” and store Michelle at “targetuser”.

Now Peter’s page must not show the “add friend” button when Michelle visiting Peter’s page. Michelle’s page also must not show “add friend” button when Peter visiting Michelle page.

How to write if else statement to show or not show the “add friend” button on their pages?
Currently I am using this method :

    $query111 = "SELECT id FROM tbl_frienRequest WHERE user='{$username1}' AND targetuser='{$username2}'";
    $result111 = mysql_query($query111,$connection) or die (mysql_error());
    confirm_query($result111);
    $requestCount = mysql_num_rows($result111);

    $query2 = "SELECT id FROM tbl_frienRequest WHERE user='{$username2}' AND targetuser='{$username1}'";
    $result2 = mysql_query($query2,$connection) or die (mysql_error());
    confirm_query($result2);
    $requestCount2 = mysql_num_rows($result2);

if (($requestCount == 0) or ($requestCount2 == 0)){
    //show "add friend" button.
}

I think it works but the codes is very long, is there any other shorten codes to get the same output?

  • 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-23T10:24:40+00:00Added an answer on May 23, 2026 at 10:24 am

    You can use an OR condition in your query:
    i.e:

    SELECT id
    FROM tbl_frienRequest
    WHERE (USER='{$username1}'
           AND targetuser='{$username2}')
      OR ( USER='{$username2}'
      AND targetuser='{$username1}'
    

    Try this:

    $query111 = "SELECT id FROM tbl_frienRequest WHERE (user='{$username1}' AND targetuser='{$username2}') OR ( user='{$username2}' AND targetuser='{$username1}')";
    $result111 = mysql_query($query111,$connection) or die (mysql_error());
    confirm_query($result111);
    $requestCount = mysql_num_rows($result111);
    if ($requestCount == 0){
                //show "add friend" button.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal is to have the url routing as following: http://www.abc.com/this-is-peter-page http://www.abc.com/this-is-john-page What is
I have a table SEND with one column Aname : Aname ------ GREAME PETER
I have the following table: Bank: name val amount John 1 2000 Peter 1
I have a table with players and scores (Name:Mike Score:10, Name:Peter Score:5, etc) and
I have a table like this: <table> <tr> <th>Firstname</th> <th>Lastname</th> </tr> <tr> <td>Peter</td> <td>Griffin</td>
I have the following database table (People): +--------+--------+--------+ | Name | Age | Time
I have this Oracle table which is used to store application settings. This is
i have a list like this [peter,1000,michell,2000,kelly,3000] and i would like to convert to
I have read this implementation of glyphs in the Expert C Programming by Peter
I have recently taken over an application that uses the Peter Blum Date and

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.