RE: Dynamic Variable Creation from Forms

From: Date: Thu, 01 Feb 2001 10:39:07 +0000
Subject: RE: Dynamic Variable Creation from Forms
Groups: php.general 
Request: Send a blank email to php-general+get-37617@lists.php.net to get a copy of this message
this works, you should be able to do something similar assigning $row["checkboxtype"] as the array key. That way you don't need to know what it's called just the array it is an element of. <?php if (isset($formvars)) { foreach ($formvars as $fvTitle => $fvValue) echo("$fvTitle:$fvValue<br>"); }; ?> <form action="#" method="post"> <?php $gotvars[fred] = "fred value"; $gotvars[bill] = "billvalue"; foreach ($gotvars as $gvTitle => $gvValue) echo("$gvTitle<input type=text name=formvars[$gvTitle] size=40 maxlength=80 value='" . $gvValue . "'><br>"); ?> <input type="submit" value="GO"> </form> Tim Ward Senior Systems Engineer Please refer to the following disclaimer in respect of this message: http://www.stivesdirect.com/e-mail-disclaimer.html > -----Original Message----- > From: [ rswfire ] [mailto:rswfire@hotmail.com] > Sent: 01 February 2001 00:29 > To: php-general@lists.php.net > Subject: Dynamic Variable Creation from Forms > > > I have a problem I'm not sure how to fix. > > PART I > > I have a form on a page that creates its variables > dynamically. Here's an > example: > > mysql_db_query($db, "SELECT * FROM table"); > while ($row = mysql_fetch_array($result)) > { > > echo "<INPUT TYPE='CHECKBOX' > NAME='chk_".$row["checkboxtype"]."'>"; > > } > > PART II > > I need to make reference to these dynamically created > variables. How do I > do this? This does not work, obviously: > > $chk_.$row["checkboxtype"] > > Thanks in advance... > _________________________________________________________________ > Get your FREE download of MSN Explorer at > http://explorer.msn.com > >

« previous php.general (#37617) next »