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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:22:20+00:00 2026-05-22T21:22:20+00:00

I know this problably sounds confusing so here is the detailed explanation: In a

  • 0

I know this problably sounds confusing so here is the detailed explanation:

In a table i have the following: customer_id, agent_id, brief_is, added_by

  1. customer id is the id for the customer

  2. agent id is the service agent

  3. brief_is is a descritpion

  4. added_by holds the id of either the customer who added it or the agent who added it.

Now i am able to get results by querying the added_by for the customer id but now i want to also adding a sorting function that will show all results where the added_by is for the customer but added by the agent_id.

Do i need to setup another field for added_for or is there another way to show these results.

Query sample:

    /* Get data. */
$sql="SELECT brief_is, customer_id, agent_id, added_by FROM the_brief 
    WHERE dcustomer_id = '$id'";  
   $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))
    {

  $cust = $row['customer_id'];
  $agent = $row['agent_id'];
  $brief = $row['brief_is'];


 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-22T21:22:21+00:00Added an answer on May 22, 2026 at 9:22 pm

    If I understood correctly, you want to improve your query by limiting (not sorting) the results to the ones where the_brief entry is added by the agent and not the customer.
    If that is the case, then all you have to do is add an extra verification to your query : agent_id=added_by.
    Now your query will look like:

    SELECT brief_is, customer_id, agent_id, added_by 
    FROM the_brief 
    WHERE customer_id = '$id'
    AND agent_id = added_by
    

    EDIT:
    Your comment lead me to the following code.Tell me if it’s the right one:

    SELECT brief_is, customer_id, agent_id, added_by 
    FROM the_brief 
    WHERE customer_id = '$id'
    AND agent_id != customer_id
    

    you can also use <> instead of !=

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

Sidebar

Related Questions

I know that this sounds trivial, but I did not realize that the sort()
I know this sounds simple, and probably is, but I can't seem ot get
First I know that this probably sounds like it isn't the best way to
This sounds like a weird title and probably not stated too well. But here's
I know this probably really simple but Im not sure what im doing wrong...
I know this is probably on the Internet somewhere but I can't find the
I know this is probably really obvious, but I cannot figure out why I
I know this is probably a really amateur question, but I can't figure this
I know this is probably possible using Streams, but I wasn't sure the correct
I know this is probably a very simple question but how would I do

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.