check duplicate

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fer0an
Forum Newbie
Posts: 12
Joined: Sat Jan 23, 2010 8:15 am

check duplicate

Post by fer0an »

hello
I've a db with some data
I want to check content, if title dosen't exist create it and if exist continue.
My db column is -->id--title--introtext--fulltext--link
anyone can help me?
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: check duplicate

Post by amargharat »

If you are going to check with "title" then you should declare "title" as an unique key. so duplicate data in a "title" field will be ignored

Now, write the code to insert the data

e.g. insert into table_name(title) values('Concept')

above query insert new entry if value "Concept" not exists.

else entry will be ignored if exists.

so no need to check the condition
Post Reply