如何,如果同一question_text
存在不插入值,但沒有爲first_word.
如果已經存在
例不要插入條目(question_text
是整個句子,第一個詞是句子中first word
。)
他很瘋狂。 //插入
他很聰明。 //插入
他很聰明。 //存在不要插入
$first_word = current(explode(' ', $_POST['question_text']));
mysql_query("INSERT INTO questions (question_id,question_text,field_name)
VALUES ('','$_POST[question_text]','$first_word')");
你不想要兩個具有相同值的條目? – powtac 2011-03-24 15:09:21
是的,我不希望插入相同的值。 – Abby 2011-03-24 15:13:21
你不能把question_text設置爲唯一嗎? – 2011-03-24 15:13:51