php - Checking for duplicates before updating a field -


i developing android application sends http requests server using php , mysql.

the user has fill in 2 fields. let's , b these added 2 columns of table (col , col b. however, want add contents of b after that. works fine.

i having problem in checking duplicates of in b. result want user enters , b of content of a+b no duplicates.

this using

$a = $_post['a']; $last_inserted_id = mysql_insert_id(); $updatetable = mysql_query("update table set b=ifnull(concat(b, '$a'), '$a')where    _id='$last_inserted_id'"); 

to make clearer, b contains words not sentence, however, sentence.

so stemmed sentence .. example a="i want learn programming" -$a= "learn programming".

so if b programming .. final result must learn , programming . i'm getting learn programming learn.

if record inserted, could've put data in there in first place. if subsequent request, mysql_insert_id() cannot trusted, other records might've been inserted.

is there precludes putting data in there in first place?

if want method append existing field, simplify defaulting b empty string, making ifnull check on concat call redundant.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -