Why loop through all of the records here, why not just add 
```sql
WHERE biblio_type = :patent_id AND (biblio_section = :section_name OR biblio_section IS NULL)
```
and let mysql do the work.