Question: I'm trying to get this to echo a warning message when the cell contains a certain text like "0" or "N/A". It would work when there was no value entered in the first place, but I can't get it to echo when there is already a certain value. Any help would be great. Thanks!

```
<?php
                $listing = "$_POST[listing]";

                $sql = "SELECT open_house_attended FROM property_flyers WHERE street_property = '$listing' ";
                $result = $conn->query($sql);

                if ($result->num_rows > 0) {
                    // output data of each row
                    while($row = $result->fetch_assoc()) {
                    echo "</span><span class='report_bignumber'><br>".  $row["open_house_attended"]."</span>";
                    }
                } else {
                    echo "<br> ". $noresults . "</span>";
                }

            ?>

```

Answer: 
You can use a little regex - 

```
if ($result->num_rows > 0) {
   // output data of each row
   while($row = $result->fetch_assoc()) {
      preg_match(trim($row["open_house_attended"]), '/[0]|[N\/A]/', $matches); // try to match '0' or 'N/A'
      if(count($matches) == 0) { // do we have matches?
          echo "</span><span class='report_bignumber'><br>".  $row["open_house_attended"]."</span>";
      } else {
           echo "<br> ". $noresults . "</span>";
      }
   }
}
?>

```

Or you can go a little more directly - 

```
if ($result->num_rows > 0) {
   // output data of each row
   while($row = $result->fetch_assoc()) {
      $ohCount = $row["open_house_attended"];
      if(( $ohCount != '0') && ($ohCount != 'N/A')) { // do we have matches?
          echo "</span><span class='report_bignumber'><br>".  $ohCount ."</span>";
      } else {
           echo "<br> ". $noresults . "</span>";
      }
   }
}
?>

```

[`preg_match()`](http://php.net/manual/en/function.preg-match.php)
```
$sql = "SELECT open_house_attended FROM property_flyers WHERE street_property = '$listing' AND open_house_attended NOT IN ('0', 'N/A')";

```

use NOT IN and a list of values to reject. It's one option anyway. The preg match option works as well, just it asks php to do the work and this asks sql to do it.