Connecting Tech Pros Worldwide Forums | Help | Site Map

Use PHP to compare fields from two different tables in same database and yield result

Newbie
 
Join Date: Mar 2008
Posts: 1
#1: Mar 26 '08
I have a module in a shopping cart program where a sellers logs in and adds product. As usual the seller logs in with an email and password which is stored in the mysql table _supplier_admins. This table also contains the field supplier_admin_name.

When the seller adds product they currently have the choice to select a manufacturer. For later reporting reasons I am attempting to change the default manufacture depending on the seller logged in. The manufacturer is stored in the mysql table _manufactuers. It should be noted this same table also contains manufactuer_id and manufacture_name. I have created product manufactures in the cart that match each sellers_admin_ name.

It should also be noted that the cart that I am using uses the manufactuer_id to select, store, display and report on information not the manufacture_name.
As stated I am attempting to create code that will change the default manufacturer based on the seller that is logged in. Both of the fields that I want to compare are VARCHAR(32). I am not sure if this matters but one is of collation latin1_swedish_ci and the other is utf8_general_ci.

I want the code to do the following:

If the supplier_admin_name from table _supplier_adminsis equal to manufacture_name from table _manufactuers then the default manufacturer will be equal to the corresponding manufactuer_id. Corresponding meaning from the same record as the matching manufacture_name.

I know very little about php and I am hoping to get help with this. I am using the Zen Cart shopping cart software. MySQL client version: 5.0.45 and PHP Version 5.25

Any help with this code would be appreciated.

Thanks in advance, dbanrman.

TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#2: Mar 26 '08

re: Use PHP to compare fields from two different tables in same database and yield result


If you want help with some code you have, you're in the right place. If you want someone to write some code for you, you need to go somewhere else. Assuming you have some code already, post it here and then tell us why it's not working or particular questions.

We don't make code, we fix code ;)

[Edit]
And use correct code tags in your post!
Reply