Page 1 of 1
Using Before Edit PHP Code Example
Posted: Wed Oct 17, 2018 5:48 pm
by tonyd
Does anyone have an example of code they have used in their "Before Edit" PHP section of a form? I am trying to wrap my head around how to use this feature in my situation, but I have brain lock and need a sharp kick in the imagination.
What I am trying to do is to programmatically set up a temp table to be used in a browse form. Also hoping for a hint on how to use a stored MySQL procedure as part of the solution.
TIA
Re: Using Before Edit PHP Code Example
Posted: Wed Oct 17, 2018 11:37 pm
by admin
tonyd,
I hope this helps.
tt1.PNG
tt2.PNG
tt3.PNG
Code: Select all
nuRunQuery("CREATE TABLE #TABLE_ID# SELECT * FROM aaa");
nuRunQuery("UPDATE #TABLE_ID# SET field00 = 'hello'");
Steven
Re: Using Before Edit PHP Code Example
Posted: Thu Oct 18, 2018 12:43 pm
by tonyd
Are you suggesting I use a hash cookie for the table name?
Re: Using Before Edit PHP Code Example
Posted: Thu Oct 18, 2018 10:12 pm
by admin
tonyd,
Yes that's correct.
Steven
Re: Using Before Edit PHP Code Example
Posted: Fri Oct 19, 2018 2:22 pm
by tonyd
Ok, cool. I got the browse form to load. Unfortunately, when I click on one of its rows I get the edit form but with all blank fields except for the subforms, which seem to have populated just fine. Any ideas?
Re: Using Before Edit PHP Code Example
Posted: Fri Oct 19, 2018 11:18 pm
by admin
tonyd,
You'll need to make sure the Primary Key is the correct field in your temp table.
This is what takes you to the correct record.
tt4.PNG
Steven
Re: Using Before Edit PHP Code Example
Posted: Sat Oct 20, 2018 1:05 pm
by tonyd
After some head scratching I finally got it to work after separating my BROWSEEDIT form into a unique BROWSE and EDIT form. Also had to add the primary key column to my select statement.
One question remains...Do I need to perform any housekeeping like dropping #TABLE_ID# before opening the EDIT form?
Thanks for all the help!
Re: Using Before Edit PHP Code Example
Posted: Sat Oct 20, 2018 10:38 pm
by admin
TonyD,
The #TABLE_ID# will drop itself.
Steven