I'm stuck in a piece of PHP/mySQL code that is driving me nuts. Hope someone can help me find the correct syntax.
Here's a part of my code:
$result = mysql_fetct_row("select count(*) from foo_tbl where foo1=$new_foo1");
if($result > 0) {
echo "You are already addded...";
} else {
mysql_query("insert into foo_tbl (foo1, foo2) values('$new_foo1', '$new_foo2')");
}
Basically I need to check whether a row already exists in a table, depending on whatever a user enters. If the row already exists, it should display a message, else it should add the row. Hmm... does this make sence at all?!?
In pseudo code it should be something like this:
User enters a text in a form and hit OK.
Check if row alteady exists in table
If row exists do something
Else do something else
Regards,
Keld Bendtsen