On 28 May 2004 12:30, Torsten Roehr wrote:

> "I.A. Gray" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi all,
> > 
> > Easy question (I hope).  My brain seems not be working today, so
> > could someone help me with this one?

[...]

> > How can I get the value to change in each form?  The name and id
> > for each input field will change from (for example) fcomposer1 to
> fcomposer30 but
> how
> > do I change the value for each input to show the variables taken
> > from the database which will be $composer1 to $composer30 ?
> > Obviously if I put in $composer$countything that will just output
> > the value of $composer followed by the value for $countything, but
> > I want it to output the value for $composer1 if $countything=1 or
> > $composer10 if $countything=10 .  Is there something I can do with
> > variable variables?  I couldn't see 
> any examples
> in
> > the PHP manual.
> 
> What you want is this:
> $temp = 'composer' . $countything;
> Then use ${$temp} -> it will efectively be $composer1.

You can also write this as

  ${'composer'.$countything}

But I'd really, really suggest looking into using arrays for this -- it looks much 
more like an array-ish problem than a variable-variable-ish problem to me.  Using 
arrays, your input fields would look like:

  <input name='fcomposer[$countything]' type='text' size='20' maxlength='60' />

and then your processing code can easily address $fcomposer[$countything] etc.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to