This topic is locked

Where Clause on Before SQL problems

6/17/2009 10:08:33 PM
PHPRunner General questions
N
nix386 author

Just wondering if someone know's how to correctly include an OR operator in the where clause on Before SQL Query on list page?

I have been trying to get the syntax right but cannot get it right.

What I have been trying to do is filter the list page for two data fields, UserAllocated and Username.

If either are populated with the sessions UserID then only those will display in the list.

global $conn;

if($_SESSION["UserID"]!="advsearch" && $_REQUEST["a"]!="search" && $_REQUEST["a"]!="showall" && !@$_REQUEST["masterkey1"])

{

$strWhereClause = whereAdd($strWhereClause, "ticket_table.UserAllocated =".$_SESSION["UserID"] OR "ticket_table.UserName ='".$_SESSION["UserID"]."'");

}


Thanks, Nick
PHPR 5.0 build 766

J
Jane 6/18/2009

Nick,
please see my changes below:

global $conn;

if($_SESSION["UserID"]!="advsearch" && $_REQUEST["a"]!="search" && $_REQUEST["a"]!="showall" && !@$_REQUEST["masterkey1"])

{

$strWhereClause = whereAdd($strWhereClause, "ticket_table.UserAllocated =".$_SESSION["UserID"]." ORticket_table.UserName ='".$_SESSION["UserID"]."'");

}

N
nix386 author 6/21/2009

Thanks Jane it's always the little things.... this is what was needed in the end.

//where clause for filtering ticket list page for My Tickets

global $conn;

if($_SESSION["UserID"]!="advsearch" && $_REQUEST["a"]!="search" && $_REQUEST["a"]!="showall" && !@$_REQUEST["masterkey1"])

{

$strWhereClause = whereAdd($strWhereClause, "ticket_table.UserAllocated ='".$_SESSION["UserID"]."' OR ticket_table.UserName ='".$_SESSION["UserID"]."'");

}