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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:49:28+00:00 2026-05-25T09:49:28+00:00

I have two tables accounts and friend_requests, here is my code… $q = $dbc

  • 0

I have two tables accounts and friend_requests, here is my code…

$q = $dbc -> prepare("SELECT * FROM friend_requests WHERE id_to = ?");
$q -> execute(array($details['id']));
$account = $q -> fetch(PDO::FETCH_ASSOC);
$result = $q -> rowCount();
if ($result < 1) {
    echo '<p>You haven\'t asked or been asked to be friends with anyone yet.</p><p>This is where you can accept or deny friend requests.</p>';
}
else {
    $q = $dbc -> prepare("SELECT * FROM accounts WHERE id = ?");
    $q -> execute(array($account['id']));
    while ($request = $q -> fetch(PDO::FETCH_ASSOC)) {
        echo '<p>' . $request['username'] . ' has requested to be friends with you.</p>';
    }
}

You will notice I check to see if anyone has requested to be friends with the user in the first sql statement by using a rowCount() if there is a row match I pull the ID from the first table to display that users information from account, is there a better way to do this with joins whilst using rowcount??

  • 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-25T09:49:29+00:00Added an answer on May 25, 2026 at 9:49 am
    $q = $dbc -> prepare ("SELECT a.* 
    FROM accounts a
    INNER JOIN friend_requests fr ON (a.id = fr.id)
    WHERE fr.id_to = ?");
    ...
    if (!$q -> rowCount())
    {
      echo 'No requests';
    }
    else 
    while ($request = $q -> fetch(PDO::FETCH_ASSOC)) { /// output}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in a teradata database that look like this accounts account_number
I have two tables on MySQL, with this structure: Users: id | name Accounts:
I have information about accounts in two tables (A, B). The records in A
I have two tables users registered_members I want to confirm values from user table
I have two tables: Accounts , which contains the information of accounts that a
I have two tables in mySQL, notably accounts and subscriber_data. I want to use
I have two tables, customers and bank accounts, with a many-to-many relationship (each user
I have two tables that I'm joining (in order to get the username from,
I have the following two tables CREATE TABLE accounts ( id INTEGER UNSIGNED NOT
I have two tables that are joined together. A has many B Normally you

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.