Thanks Paul...,

That makes a lot of sense.  My first thought is to place the files in
question in a particular subdirectory and do a readdir to populate the
array.



> -----Original Message-----
> From: Paul Chvostek [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 21, 2004 11:18 PM
> To: Alex Hogan
> Cc: PHP General list
> Subject: Re: Form woes
> 
> Alex,
> 
> A switch statement probable isn't the way you want to do this.  There is
> no real limit to how many of anything should go in a page, but there are
> likely better ways to skin this particular cat.  Your goal should be to
> come up with elegant ways to represent problems, such that large tasks
> can be achieved using minimal code.
> 
> I'd put your includes in an array.  Based on your code, something like:
> 
> <?
> 
> $pages=array(
>     1 => 'create_lsn_name',
>     2 => 'create_lsn_obj',
>     3 => 'create_gain',
>     4 => 'lsn_layout',
>     5 => 'dev_lsn_page',
> );
> 
> if ($pages[$_GET['dev']]) {
>     printf("<form action='create_lesson.php?dev=%s'\n", $_GET['dev']);
>     include($pages[$_GET['dev']] . '.php');
>     print "</form>\n";
> } else {
>     include('create_lsn_name.php');
> }
> 
> if ($_GET['dev'] < 5) {
>     $dev=$_GET['dev']+1;
> }
> 
> ?>
> 
> Now, adding to the include list is just a matter of updating the array.
> Of course, this doesn't address the issue of navigation *backwards*
> through the page list.
> 
> p
> 
> 
> On Wed, Jan 21, 2004 at 01:07:58PM -0600, Alex Hogan wrote:
> >
> > The code below is the submission of my form and the inclusion of
> different
> > pages based on what the $dev value is.
> >
> >
> >
> > My questions are;
> >
> > Is there a better, or should I say more elegant, way to do what I'm
> doing?
> >
> > Should I break out the switch statement and put it in another page?
> >
> > What is the suggested limit, for clarity of reading and maintaining, for
> the
> > number of pages included in a single page?
> >
> >
> >
> > My goal is to make this extremely easy to edit and maintain.  If I can
> make
> > a single change in one page that can affect many other pages I should
> break
> > up the pages, shouldn't I?
> >
> >
> >
> > Sorry for the bombardment of questions.
> >
> >
> >
> > [code]
> >
> > <td align="left" valign="top"><form
> action="create_lesson.php?dev=<?=$dev?>"
> > method="post" name="frmCreateLesson" class="normal_text"
> > id="frmCreateLesson">
> >
> > <?
> >
> > switch($_GET['dev']){
> >
> > case 1:
> >
> >                         include('create_lsn_name.php');
> >
> >                         $dev = 2;
> >
> >                         break;
> >
> >             case 2:
> >
> >                         include('create_lsn_obj.php');
> >
> >                         $dev = 3;
> >
> >                         break;
> >
> >             case 3:
> >
> >                         include('create_gain.php');
> >
> >                         $dev = 4;
> >
> >                         break;
> >
> >             case 4:
> >
> >                         include('lsn_layout.php');
> >
> >                         $dev = 5;
> >
> >                         break;
> >
> >             case 5:
> >
> >                         include('dev_lsn_page.php');
> >
> >                         break;
> >
> >             default:
> >
> >                         include('create_lsn_name.php');
> >
> >                         break;
> >
> > }
> >
> >
> >
> > ?>
> >
> >  [/code]
> >
> >
> >
> > alex hogan
> >
> >
> >
> >
> >
> > ******************************************************************
> > The contents of this e-mail and any files transmitted with it are
> > confidential and intended solely for the use of the individual or
> > entity to whom it is addressed.  The views stated herein do not
> > necessarily represent the view of the company.  If you are not the
> > intended recipient of this e-mail you may not copy, forward,
> > disclose, or otherwise use it or any part of it in any form
> > whatsoever.  If you have received this e-mail in error please
> > e-mail the sender.
> > ******************************************************************
> >
> >
> 
> --
>   Paul Chvostek                                             <[EMAIL PROTECTED]>
>   it.canada                                            http://www.it.ca/
>   Free PHP web hosting!                            http://www.it.ca/web/


****************************************************************** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
****************************************************************** 


Reply via email to