This topic is locked

lookup wizard and custom where clause

7/14/2006 2:22:47 AM
PHPRunner General questions
D
Dale author

Using the lookup wizard I would like the picklist to be generated with only ONE name.
I am trying to use the custom expression in the where field on the lookup wizard.
I want a list of customer names that match the current @$_SESSION[$strTableName."_masterkey"] value.
I have been trying the below syntax.
User record linked to Customer table

link field customer_id

display field name
Where field "customer_id=`".@$_SESSION[$strTableName."_masterkey"]."`"
Either I am getting, Cant request data with the current where clause.
or
after jerking with the periods and commas , I get past the picklist part, but when I generate and open the edit page I get a parse error.
Clear out the where, everything works fine, EXCEPT in the body of the output I get all 16 hundred of my customers names in the array for the picklist. I only want the names of customers that match the the current @$_SESSION[$strTableName."_masterkey"] which most often will be just one customer name.
I hope Ive explained this okay.
Am I missing something basic in my syntax. I'm hoping your experienced eye can point me to my error.
@$_SESSION[$strTableName."_masterkey"]

J
Jane 7/14/2006

Dale,
Here is correct expression if customer_id is a text field:

"customer_id='".@$_SESSION[$strTableName."_masterkey"]."'"



If customer_id is a numeric field don't use single quotes in your expression.
Backquotes are used for the identification of the field or table.

D
Dale author 7/14/2006

Thankyou Jane.
I am beginning to have nightmares about comma's, quotes, periods etc.
Thanks for your response.

I will try it out asap.

D
Dale author 7/14/2006

I must be doing something not right still.
I cut and pasted you example into the field.
"customer_id='".@$_SESSION[$strTableName."_masterkey"]."'"
The customer_id field is a numeric so I took out the single quotes.
Test it. Cant retrieve data.
Put the single quotes back in.

test it. Lookup wizard Test displays. No data in the test lookup box, but no error.

( Im thinking the test may not know what value the @$_SESSION[$strTableName."_masterkey"] at test time)
Build it, and when I open the list, it displays, but the NAMES are not just the customer #.

But, select and I get PHP error Undefined variable: strTableName
Back to the lookup wizard and remove the where and everything works fine.

But the complete array of Customer names are in the html body. I dont want customers to see other customers names. The customers are competitors.
I know this has been talked about before in other posts, there doesnt seem to be a performance issue, although with a large 100000 customer database, its got to be a hit.
But anyway, Im just trying to limit the picklist to the one item. If you make the id field read only, you cannot get the Name value to display, you only get the associated number id.
I have cleared the where clause and disabled the field on the edit form so at least users cant view the picklist. I hope there is a trick to get that where clause working. Would give me the flexibility I need.

D
Dale author 7/14/2006

PHPRunner is great. I can produce a very nice professional website with the program.
Just to clear up my venting, My real complaint is I cant set a field to read only on the edit page that uses a lookup and have it display the same way as it would in a list. In the edit view it would only display the link field value and not the Display value.
Sorry for the venting.

Maybe something to add to the wish list. To set a field to readonly but use the lookup wizard for how you want the field data displayed.

kujox 7/16/2006

Im thinking the test may not know what value the @$_SESSION[$strTableName."_masterkey"] at test time


I suspect you're right, how can it display the record you want when the masterkey equals nothing, but it would be handy to have a field from a record id

D
Dale author 7/17/2006

Issue solved.
When you set the field to readonly, PHPRunner will only display the link field data and not the Display field data on a Edit page.
I left the field as read only, then modified the ...edit.php to do a lookup for the Display field to display the customer name instead of the customer number. And now no array list of all my customers in the ...Edit page html.
It would be nice IF PHPRunner would still use the lookup wizard settings, even though you flag the field as read only on the field.
Great product and great forum.

Would like to see a list of example syntax snippets. The . , " ' are a killer. Actual sample snippets of how to format the custom expressions we are allowed to use.
Thankyou all for your time and suggestions.