Re: [Nolug] php help: storing from variable # of form entries

From: Brett D. Estrade <estrabd_at_yahoo.com>
Date: Wed, 27 Aug 2003 05:49:17 -0700 (PDT)
Message-ID: <20030827124917.25065.qmail@web41510.mail.yahoo.com>

oops...I spotted some obvious errors now that I am awake!

 <!-- html -->
 <form action="<?echo $PHP_SELF;?>" method="post">
 <?
 /* php */
 for ($i=0;$i < $_POST('SomeNumberToCreate');$i++) {
   ?>
     <input type="text" name="VariableTextInput_<?echo $i;?>" value="">
   <?
 }
 ?>
 <input type="submit">
 </form>

--- "Brett D. Estrade" <estrabd@yahoo.com> wrote:
> I think I understand - check out a page I did a couple of years ago -
> http://www.thetaxi.org/Chapters/Forms/amform.php
>
> You select how many entries you want to, then it recycles the page to produce that many
> available
> entries.
>
> Basically what you do is this:
>
> <!-- html -->
> <form action="<?$PHP_SELF?>" method="post">
> <?
> /* php */
> for ($i=0;$i <= $_POST('SomeNumberToCreate';$i++) {
> ?>
> <input type="text" name="VariableTextInput_<?echo $i;?>" value="">
> <?
> }
> ?>
>
> <input type="submit">
> </form>
>
> Then you can use one of Scott's suggestions to process that input....
>
> Hope this helps, feel free to contact me with further questions.
>
> Brett
> --- Scott Harney <scotth@scottharney.com> wrote:
> > "Christopher M. Jones" <cjones12@tulane.edu> writes:
> >
> > > I am just learning some php to make a web application. I have hit upon
> > > what is (to me) an insuperable problem. I need to create a form page
> > > that presents a variable number of inputs. The php needs to iterate
> > > through this variable number of form inputs to store the data into a
> > > database.
> > >
> > > For example, a list of students is presented (size of class varies)
> > > along with entry fields for grades. Hit a button at the bottom of the
> > > page and all entered grades are stored.
> > >
> > > The problem I have is how to iterate the name of the variable from the
> > > <input name=<varname>> tag. Does this make sense? I have been unable
> > > to find example code that does what I want. Maybe someone could at
> > > least point me in the right direction?
> >
> > php populates array $_GET or $_POST depending on the form type
> > you use.
> >
> > foreach ($_GET as $varname) {
> > //do something
> > }
> > OR
> > foreach ($_GET as $key => $value {
> > echo "$key => $value"
> > }
> >
> > also see for loop documenation and docs for the each() function
> > on php.net
> >
> > --
> > Scott Harney<scotth@scottharney.com>
> > "...and one script to rule them all."
> > gpg key fingerprint=7125 0BD3 8EC4 08D7 321D CEE9 F024 7DA6 0BC7 94E5
> > ___________________
> > Nolug mailing list
> > nolug@nolug.org
>
>
> =====
> http://www.brettsbsd.net/~estrabd
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> ___________________
> Nolug mailing list
> nolug@nolug.org

=====
http://www.brettsbsd.net/~estrabd

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
___________________
Nolug mailing list
nolug@nolug.org
Received on 08/27/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST