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
-
customer id is the id for the customer
-
agent id is the service agent
-
brief_is is a descritpion
-
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("");
}
}
If I understood correctly, you want to improve your query by limiting (not sorting) the results to the ones where
the_briefentry 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:
EDIT:
Your comment lead me to the following code.Tell me if it’s the right one:
you can also use
<>instead of!=