I don't know if the title explains my problem very well, but this is what I have:
$query = "SELECT * FROM eny_yarn_identifier WHERE yarnName=\"{$_POST['interest']}\"";
if (isset($yarnColor))
{
$query .= " AND yarnColor=\"{$_POST['interest']}\"";
}
$result = mysql_query($query)
or die ("Couldn't execute query.");
$nrows = mysql_num_rows($result);
It works great if both of the fields are used, but if one is not use, there is no result. Can you tell me what I am doing wrong? Please, if this code makes no sense at all keep in mind I have only been using php and mysql for two days.
Any help would be greatly appreciated!
Thanks,
phpkata
$query = "SELECT * FROM eny_yarn_identifier WHERE yarnName=\"{$_POST['interest']}\"";
if (isset($yarnColor))
{
$query .= " AND yarnColor=\"{$_POST['interest']}\"";
}
$result = mysql_query($query)
or die ("Couldn't execute query.");
$nrows = mysql_num_rows($result);
It works great if both of the fields are used, but if one is not use, there is no result. Can you tell me what I am doing wrong? Please, if this code makes no sense at all keep in mind I have only been using php and mysql for two days.
Any help would be greatly appreciated!
Thanks,
phpkata