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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:06:38+00:00 2026-05-26T01:06:38+00:00

I have had a long problem with this code. I have posted this question

  • 0

I have had a long problem with this code. I have posted this question multiple times on SOF but never was able to clearly state the problem but now i can.

I want to be able to see posts by other agents for my clients. So in this query i shouldn’t be able to see the posts added by me for my clients but posts for my clients added by other agents. Below is what i have been trying. The good thing is that the code does what i need to but then it shows me posts that are not for my clients too. So i am not sure where I need to make the tweak?

Code:

$type1 = "Added by Other Agents"
$myuserid = My id.  So i am using <> to not show posts added by me for my clients. 

$sql = "SELECT posts.posts_id, accounts.full_name,
agents.agent_name, posts.person_id, posts.why_posts, 
posts.just_date, posts.type, posts.date_time_added FROM 
posts LEFT JOIN accounts ON posts.person_id = accounts.person_id 
LEFT JOIN agents on posts.agent_whois = agents.agent_id WHERE 
(posts.type = '$type1') and  
(posts.added_by <> '$myuserid')"; 
$result=mysql_query($sql);

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

if ($result == "")
{
echo "";
}
echo "";


$rows = mysql_num_rows($result);

if($rows == 0)
{
print("");

}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{

$postsid = $row['posts_id'];
$agentwho = $row['person_id'];
$agentname = $row['agent_name'];
$reason = $row['why_posts'];
$datetimeadded = $row['just_date'];
$name = $row['full_name'];
$type = $row['type'];


print("");
}

}
  • 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-26T01:06:39+00:00Added an answer on May 26, 2026 at 1:06 am

    If the accounts table stores which agent is associated with a client, then you need to add an additional condition to specify accounts that are only associated to you. Since it is still unclear to me which field that is, let’s say it’s called accounts.agent_owner

    In this part of your SQL:

    FROM posts
    LEFT JOIN accounts ON (posts.person_id = accounts.person_id)
    LEFT JOIN agents ON (posts.agent_whois = agents.agent_id)
    WHERE (posts_type = '$type1') AND (posts.added_by <> '$myuserid')
    

    Add:

        AND accounts.agent_owner = '$myuserid'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have had to do this several times, usually when trying to find in
I've had this problem many times: I create HTML dynamically via jQuery, and in
One thing with which I have long had problems, within the CakePHP framework, is
We have had SharePoint where I work for a little while now, but we've
We have/had a phantom delay in our app. This was traced to the initialisation
I posted a question not to long ago about how my program was essentially
I've spent a great long while googling this problem without any luck and I've
I have a problem with Gridview sorting that is similar to others but I'm
I have a computational algebra task I need to code up. The problem is
I'm using this code to get the pixels from a bmp file. I have

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.