It seems that I'm asking a simple question but I haven't been able to find an answer that works for me. I hope you can help!
I'm writing a php script that takes some form data from an html-file (name, artist, song)
and put it into a table with the columns (name, artist, song, queue, newcomer)
. Now, the column newcomer
is a boolean; and I want this boolean value to change from the default of false or 0, to true, or 1, if the name value of the incoming form data is unique.
This is my try:
$newcomer = mysql_query(
'IF NOT EXISTS (SELECT DISTINCT name FROM tbl_queue)
THEN UPDATE tbl_queue newcomer=1'
);
but obviously, it doesn't work...
Thanks in advance!!
Hi and thanks for the answer! HOwever it still doesn't work for me =( THis is the code from the php:
$newcomer = mysql_query("UPDATE tbl_queue SET newcomer=1 WHERE name='" . $_POST[name] . "' AND NOT EXISTS (SELECT DISTINCT name FROM tbl_queue WHERE name='" . $_POST[name] . "')" );