Jump to content

how to check for duplicate first? before adding a record.


bilis_money

Recommended Posts

I know this is very basic question.
I had been into a vacation for about 4 months, now
i don't know where to begin this very newbie problem in php & mysql.

I hope someone would help me here.

here is the problem;
I have a table "products" now i want to add records,
i know how to add records but what i want really is to check
for existing record in the table first before adding the new record.

i want the duplicate checking to search from top to bottom of the record
looking for duplicates then if there is none then add the record.

i hope someone would guide me i'm really now confuse where to begin...

a sample snippet of codes is very highly appreciated.



Thanks a TON for advance.
Before adding the record, do a SELECT based on the information you don't want duplicated. IE, if it's a `product_name` field, do
"SELECT product_id FROM products WHERE product_name = '$name'";
Edit to match your table.

If you get any ids back, then you know it's a duplicate.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.