I believe you are missing two things:
1) quotes around your value. Are they all integers? Even if they are, a quote wouldn't hurt you (nor the query) :
$query .= "AND $key = '$value'";
2) Your query will have an extra AND right after the WHERE:
... FROM articles WHERE AND key = 'value', etc...
so you need to ONLY add the "AND" if it's NOT the first key/value pair:
$firstclause = true;
foreach($articlename && $articlenum && $date && $partnum && $model as $key => $value)
{
if(!$firstclause) {
$query .= "AND ";
}
else {
$firstclause = false;
}
if(!empty($input[$key]))
{
$query .= "$key = '$value'";
}
}
hope it works out!
-sridhar