I'm running a dynamic query and noticed I was not
getting the results expected.  

Here I make the declaration for the query array:
$aWHERE = array();

Then test what variables came back from input:
if(!empty($aWHERE)) {
$query_rsCS .= ' WHERE '.implode(' AND ',$aWHERE);

Here is the problem. I have one field in the form that
is set to search 1 table on 1 field and another table
on 2 fields:

if(!empty($sCanEmail)) $aWHERE[] = "Reg.email LIKE
if(!empty($sCanEmail)) $aWHERE[] =
"Profiles_AddContacts.eml2 LIKE '%$sCanEmail%'";
if(!empty($sCanEmail)) $aWHERE[] =
"Profiles_AddContacts.eml3 LIKE '%$sCanEmail%'";

So, if an email addy is not found in all 3 fields then
nada is returned.  Obviously ! (all AND statements)

Right now my thinking is I "might" need to break these
particular "where" conditions off into a seperate
Something like: $bWHERE = array();
then - 
$query_rsCS .= ' WHERE '.implode(' OR ',$bWHERE);

Or is it possible there is another work around I'm not
seeing yet ?

Thanks in advance.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to