I have a function to let user to key in multiple discount code separated by comma. Problem is that if the user key in one valid key and one invalid key, it will still go through the system because mysql\_num\_rows detects the valid key in db is more than 0.

How to do make it even if user key in multiple valid key but one invalid key, it will still prompt out error message, it won't go to the else statement.

```
$dc_input = $_POST['discount_code'];
$dc_delspaces = preg_replace('/\s+/', '', $dc_input);
$dc_array = explode(',', $dc_delspaces);

$row = mysql_query("SELECT * FROM discount_code WHERE disc_code IN('" .implode( "','", $dc_array )."')") or die(mysql_error());

if (mysql_num_rows($row) == 0){
$invalid_code = "<p style=\"color:red\"><b>Invalid Code!</b></p>";
}

```