Oh brother - I can't believe I'm asking this as I know that I know the answer - I just can't seem to figure it out.
I want to query a table in a database (using PHP) to see if a particular thing exists. For this example I'll say I'm looking to see if there is a value of a color in the column color. If the color is in the database, I would like to ouput "This color was already added." If the color is not in the database I would like to output "The color was not found; you should add it now."
So I tried something like this:
PHP Code:
$sql = mysql_query("SELECT * FROM `table` WHERE `color` = '".$_GET['color']."'");
if(!$result) {
echo 'This color was not found; you should add it now.';
} else {
echo 'This color was already added';
}
But I keep getting the message "This color was already added" when I know that it's not there.
Hoping someone will be able to help
