Thank you so much for responding.
I hate to admit this (it's rather embarassing really), but it turns out that it was a simple solution.
After making some backups of the file, removing almost everything except the sql statement in question, and trying section by section, it turns out that where I had:
<script language = javascript>
<!--
it turns out that after my functions, I had left out a '--> at the end. Thus, all of the HTML in the page was being read as comments, so I got blank screens with working code.
I'm sorry, hopefully this will at least serve to emphasize to someone how important it is to ensure that you have both opening and closing syntax for everything.
It also indicates how a very simple problem can sometimes be extremely hard to find. Anyway again, thank you.
**************
Though I still don't know why it only happens when the 'WHERE' clause is added. Doesn't make sense to me. But it does work now.