unique field?

admin

Administrator
Staff member
I have a script that inserts data into two tables....and I don't want there to be any double ups on a field "lastname" in the first table. If I make it a unique field, then the second table still gets data inputed into it even though the first table doesn't.

Do I really have to query the database first to see if the same lastname already exists.....or can I use some other function that recognises when a double-up has occurred so I can then tell it to skip the next INSERT?

Kinda Like:

$sql = mysql_query("INSERT INTO $table blah blah");

if(!$sql)
{
//insert data into the next table
}

else
{
//tell me there been a double up.
}

rgds,
scott d~
 
Back
Top