This is a query, maybe a ‘double query’ that I am using. The customer id is an id number for the customer. The customer name is the associated name. The prodid is a product id number for a product(s) that the customers sell in the php storefront.
The issue is this: I want to only show the products that are associated with a certain customer in the table. In other words, if an administrator from store 1 logs in, I only want that admin to see products associated with the customer he/she represents. However, this query seems to be showing all products in the database without regard for the customer id. Yes, each product has a customer id associated with it. Each admin has a customer id associated with it.
I’d like php/mysql to query one table (admins) to see which customer id the admin is associated with AND display only those records from the products table with that admin’s customer id number.
Any ideas? Thanks in advance.
[php]
$query=“SELECT custid, custname from customers where adminid=adminid”;
$result=mysql_query($query);
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
$custid = $row['custid'];
$restname = $row['custname'];
$query2="SELECT count(prodid) FROM products WHERE custid = $custid";
$result2 = mysql_query($query2);
$row=mysql_fetch_array($result2);
$total = $row[0];
echo "<a href=\"smalladmin.php?content=testerpage&custid=$custid\">$custname</a> ($total)<br>\n";
}
[/php]