How do I write an if statement in PHP that checks a database for $varialbe and have it only pe开发者_运维问答rform the action if $varialbe is not already in the database?
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
if (! DBA::RowExists("select 1 from table where key = '$varialbe'"))
{
...
}
加载中,请稍侯......
精彩评论