PHP Programming > General PHP Help

What's wrong with this query?

<< < (3/9) > >>

traydavid:
The count function wouldn't throw that error would it?  Thanks.

traydavid:
Thank you.  I can appreciate that. 

The second query is calling up products from the products table that are associated with the customer id number of the admin.  Each admin has an admin id number (to identify each unique administrator) and a customer id number associated with said admin.  I'm trying to make the code select all the products in the products table that have the same customer id number as the admin has.  The only way to find out the admin's customer id number is to first query the admins table where this data is located. 

The admin table has admin name, admin id number, admin customer number, admin password.

Query the admins table when admin logs in to get the admin's customer id number, or the company he works for, called a customer in my database.  Compare that customer id number to all the products in the products table.  This would tell us which products belong to this admin's customer, or employer.  Then display those on the page for the admin to see/change. 

Hope this helps.  Yes, there are going to be many products, about 20-30, that match each admin's customer id number. 

traydavid:
I changed adminid to $adminid.  Now it says that variable is undefined.

That's the problem I'm having.  I'm trying query the ADMINS table and get the admin's id number who just logged in.  Then pull that admin's customer id number from the ADMINS table.

THEN compare this number (customer id number) to the products in the PRODUCTS table against each product's customer id number.  This would then display all the products that belong to that customer, based on which admin has logged in.  I call it a double query because I'm trying to query one table and get that data, temporarily hold it and use it to pull data out of a second table using a second query. 

I know this is difficult problem.  Two weeks for me now.  Thanks for all the thought.

traydavid:
more info...

admins table:  name, password, adminid number, customer id number

products table:  product name, customer id number, price, description, etc.

Query one:  an administrator just logged in.  Query the admins table and get his customer id number.

Query two:  compare that customer id number to all the products in the products table and display all the products that have the same customer id number as this admin

Hope this helps.

ErnieAlex:
I really think it is a simple problem, it's just trying to solve it long distance...  LOL
And, I have been busy...  Anyway, got time now and the next couple days...  Let's solve it...

Okay, where is the admin's id coming from?  Is this code you posted, did the admin number come from a form?  You are basing your first query on it and I assumed the problem was in the second query, not the first.  I am sorry I didn't catch it at first.  Normally, when you let a user or admin log in, you check their userid and password.  When they are validated and okay'd, you usually save the userid or adminid in a variable or session variable.  Then, you use that for your query.  Like your first query.  Where do you get your adminid from?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version