tags:

views:

45

answers:

3

How do I write an IF statment in php that checks a database for $varialbe and have it only perform the action if $varialbe is not already in the database.

+2  A: 

You can count number of items in database by SELECT count(*) FROM table WHERE field=? query, and then insert record if there is no such records.

You can also add UNIQUE index to the table column you want to have only unique values

Ivan Nevostruev
+1  A: 

if (! DBA::RowExists("select 1 from table where key = '$varialbe'")) {
...
}

Don
A: 

You can stop having us do your homework.

Look at this user's question history: http://stackoverflow.com/users/201349/unknown-google

sirlancelot