PHPMYADMIN & PHP Help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
macintoshmellish
Forum Newbie
Posts: 2
Joined: Fri Feb 04, 2011 10:29 am

PHPMYADMIN & PHP Help

Post by macintoshmellish »

I'm Currently writing a program for a Shop to use as Online Ordering System.

It involves it being used at a wholesalers so that admin's in the shop can see what is being purchased.

The program runs off a PHPMYADMIN Database 'Products', It is common at the wholesalers to buy a certain product from more than one supplier, to overcome this, I have added a feature on the UI for the User to temporarily add a new product in, in this instance a second purchase of the same product from a different from.

The Problem I am having is that the Database is not allow duplicate Product names to be entered in, therefore a second sale cannot be filled in.

Does anyone know how to give each product a unique identifier, for example a number, so that the table can accept duplicate names of products.

Thank You :D
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: PHPMYADMIN & PHP Help

Post by John Cartwright »

You probably want to create another table, like product_names or something, which has an auto incremented primary key, and another column for the name, among other details you might want to include. Then in your products table, store the reference of the product_names id (primary key).

That, or remove the unique key constraint on your products table.
macintoshmellish
Forum Newbie
Posts: 2
Joined: Fri Feb 04, 2011 10:29 am

Re: PHPMYADMIN & PHP Help

Post by macintoshmellish »

John Cartwright - Thank you for your quick response to my previous post, I found your advice very useful with my project, However I do believe I have not quite worded my first post as well as I possibly could have. The situation of being able to buy a single product (featured in a PHPMYADMIN Database) 'Products', must be able to be withdrawn by the administrator on the UI and then filled out with the appropriate text fields relating to that product, for example 'Product 1' will be withdrawn from the database and then the text fields of 'quantity' and 'cost' will have to be filled in. Please be aware that this may have to be done more than once in one day, therefore when the information is sent to an Archiving Database, it must be able to recognise that it has been purchased on two separate occasions. If there is any tips or help you can give to assist me, it would be greatly appreciated.
Post Reply