[FX.php List] Creating Reusable Code - Part II
Jonathan Schwartz
jonathan at eschwartz.com
Sun Sep 10 01:07:54 MDT 2006
This is the continuing mini-challenge of creating re-usable modules
of scripting that can be easily re-purposed. Thanks to the Andy and
Dan, I was able successfully pry the data and scripting apart, using
a series of arrays to store the variables rather than have them
appear hard-coded into the script. This works fine.
My next step was to remove the arrays from the script altogether and
put the arrays in a separate php (arraysdata.php) file. I used an
include to have the arrays load when the primary script page loads.
This works fine.
Then, I created a second copy of the arrays in the same file which
define a completely different database, layout and field names. I
commented out the first set and used just the second set. This works
fine.
So now my challenge is to figure out how to set things up to have the
right set of arrays load, transforming the primary script from
Purpose A to Purpose B.
Users arrive to pages by either clicking on a navigation bar which
contains a link (searchPage.php), or, they might clink on a page
which delivers them to the new page.
I know I need to set a variable that defines the current arrays that
should be loaded and remain loaded for the current searchPage until
the users leave the page. With that variable set, I could use an
if/else statement in the arraydata.php page to load the desired set
of array data.
I'm not sure whether to use a session variable or a regular variable,
and more importantly, how to do that from a URL link
(searchPage.php?).
I did try adding a parameter to the searchPage.php link:
searchPage.php?arrayset=A. Then, I added a statement to the beginnig
of the target page (searchPage.php) to pick up the variable:
$arrayset = $_GET['arrayset']. It did pick up the variable.
However, I would lose the variable after the first search was
performed. I also tried setting the variable to a session variable,
but then it would also be reset after the first search.
If I'm on the right track, I guess that I need to work out how to
keep that variable set for the duration of the user session on that
page, until the next array set is required.
If I'm totally wrong, I'd like to know that now.
Am I on the right track?
jonathan
--
Jonathan Schwartz
FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance
Schwartz & Company
jonathan at eschwartz.com
http://www.eschwartz.com
http://www.exit445.com
415-381-1852
More information about the FX.php_List
mailing list