Trying to avoid repetition in database

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
Ozz
Forum Commoner
Posts: 26
Joined: Wed Aug 21, 2002 11:47 pm

Trying to avoid repetition in database

Post by Ozz »

I use a form to send links to my site.
Its a link log type site.
I want to inform submitter when a link exist on database to avoid repetition.
table name is weblog column name is body in my MySql database.
How can I do that in php with a database query ?
Thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you might mark the field as unique. Atempts to add an equal entry will be rejected by msql.
Or you perform a query with the apropriate WHERE-clause. if mysql_num_rows returns a value !=0 there was an equal entry and you may show it.
Ozz
Forum Commoner
Posts: 26
Joined: Wed Aug 21, 2002 11:47 pm

Post by Ozz »

Body field is not only url it has some text and html tags.
Is there query to search within the body field?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

are you sure you want to store the data that way?
You have to extract any link from the posted message either way, so you could easily store them in a different field or cross-linked table.
Anyway, maybe these two links are helpful
http://www.mysql.com/doc/en/String_comp ... tions.html
http://www.mysql.com/doc/en/Fulltext_Search.html
Ozz
Forum Commoner
Posts: 26
Joined: Wed Aug 21, 2002 11:47 pm

Post by Ozz »

I think it will be like a full text searching.
Thanks
Post Reply