This topic is locked
[SOLVED]

 Need help with selecting multiple dropdown

9/2/2010 7:38:19 PM
PHPRunner General questions
R
rod author

Hi, I have been struggling with coming up with a way to allow controlling combo box content on the "add" & "edit" pages depending on a couple of different options.
My project has three tables, items (main table), users and districts. I have within the users table two fields that control my desired combo box on the add page for items. These two fields within users are "admin" and "district-id", where admin and district-id are int(11) type. I want to control the combo box by checking the current logged-in user and if the users "admin" field is a 1, or 3 I want to list all users except for those with "admin" 1 or 3. Otherwise I only wish to list the users that have the same district-id values. I am creating $_SESSION[admin] and $_SESSION[district-id] variables when the user logs-in.
Or another way is:
admin district-id list users by

1 or 3 any > 1 all users except those with admin in (1,3)

others any only those users that match by district-id's
I have tried coming up with MySQL $strWhereClause in edit page -before SQL (there is not one for add page?). I have also tried creating customQuerry events...I have also tried using the lookup table "where" option, but I can only do one or the other method this way, not both.

I am now quite stuck with this one. If you have any ideas I can try, or another better method of doing this, let me know. My project is still in the design phase, so changes can be made easily.
Thanks,

Rod

Sergey Kornilov admin 9/2/2010

Here is the idea of how you can do that

  1. In Lookup WIzard WHERE box put a session variable like $_SESSION["MyWhere"]
  2. Use Add page BeforeProcess event to populate this variable:

if (($_SESSION["admin"]==1 || $_SESSION["admin"]==3) && $_SESSION["district-id"]>1)

$_SESSION["MyWhere"] = " admin<>1 and admin<>3";

else

$_SESSION["MyWhere"] = " district-id=".$_SESSION["district-id"];
R
rod author 9/3/2010



Here is the idea of how you can do that

  1. In Lookup WIzard WHERE box put a session variable like $_SESSION["MyWhere"]
  2. Use Add page BeforeProcess event to populate this variable:

if (($_SESSION["admin"]==1 || $_SESSION["admin"]==3) && $_SESSION["district-id"]>1)

$_SESSION["MyWhere"] = " admin<>1 and admin<>3";

else

$_SESSION["MyWhere"] = " district-id=".$_SESSION["district-id"];



Sergey,
Thanks, that got me past that problem. Didn't think of using session variable for where control outside of the lookup table's WHERE-box. Great answer.